File: schema_valid_vs_invalid.rb

package info (click to toggle)
ruby-dry-types 1.2.2-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 504 kB
  • sloc: ruby: 3,059; makefile: 4
file content (21 lines) | stat: -rw-r--r-- 345 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# frozen_string_literal: true

require_relative 'setup'

VALID_INPUT = {
  name: 'John',
  age: 20,
  email: 'john@doe.com'
}

INVALID_INPUT = {
  name: :John,
  age: '20',
  email: nil
}

Benchmark.ips do |x|
  x.report("valid input") { PersonSchema.(VALID_INPUT) }
  x.report("invalid input") { PersonSchema.(INVALID_INPUT) }
  x.compare!
end