Sha256: 611f169857a3e6c4250c9dfdf97c848a2a55310fe997a598c65292aa4b7238f7

Contents?: true

Size: 791 Bytes

Versions: 2

Compression:

Stored size: 791 Bytes

Contents

#!/usr/bin/env ruby

require "bundler/setup"
require "schema_serializer"

User = Struct.new(:id, :name, :age, :gender, :email, :created_at)
User.include SchemaSerializer::Serializable
users = Array.new(1_000_000) { |i|
  User.new(i.to_s, "abcdefg", rand(80).to_s, rand(2).to_s, "user#{i}@example.com", Time.now)
}
SchemaSerializer.definition = {
  "User" => {
    "required" => %w(id name),
    "properties" => {
      "id" => { "type" => "integer" },
      "name" => { "type" => "string" },
      "age" => { "type" => "integer" },
      "gender" => { "type" => "integer" },
      "email" => { "type" => "string" },
      "created_at" => { "type" => "string" },
    },
  },
}

start_at = Time.now
users.each do |user|
  user.serializer.as_json
end
elapsed = Time.now - start_at
puts elapsed

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
schema_serializer-0.2.7 bin/profile
schema_serializer-0.2.6 bin/profile