Skip to content

Instantly share code, notes, and snippets.

@muhammadn
Last active August 29, 2015 14:23
Show Gist options
  • Save muhammadn/b16a6b5d8396a3ee8283 to your computer and use it in GitHub Desktop.
Save muhammadn/b16a6b5d8396a3ee8283 to your computer and use it in GitHub Desktop.
Benchmark MongoDB
#!/usr/bin/env ruby
require 'mongoid'
Mongoid.load!(File.expand_path('mongoid.yml', './config'))
class PageView
include Mongoid::Document
field :anonymous_id, type: String
field :session_id, type: String
field :fingerprintjs_id, type: String
field :app_key, type: String
field :url, type: String
field :user_agent, type: String
field :ip, type: String
field :referrer, type: String
field :received_at, type: String
field :client_timestamp, type: String
field :end_user_id, type: Integer
field :page_view_client_key, type: String
field :keywords, type: String
field :description, type: String
field :title, type: String
field :email, type: String
field :processed_at, type: String
field :app_id, type: Integer
field :achievement_processed_at, type: String
field :keywords_processed_at, type: String
field :month_code, type: Integer
field :day_code, type: Integer
end
beginning = Time.now
for i in 1..2000 do
PageView.create!(anonymous_id: "123123123", session_id: "123123213", fingerprintjs_id: "12312312313", app_key: "12312313", url: "http://localhost", user_agent: "Mozilla", ip: "127.0.0.1", referrer: "http://www.sg", received_at: "time", client_timestamp: "time", end_user_id: "12312", page_view_client_key: "12312313", keywords: "My keyword", description: "My description", title: "My title", email: "zaihan@unrealasia.net", processed_at: "time", app_id: "123123", achievement_processed_at: "time", keywords_processed_at: "time", month_code: "12", day_code: "!2")
end
puts "Time elapsed: #{Time.now - beginning} seconds."
staging:
sessions:
default:
database: mongotest
hosts:
- localhost:27017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment