Skip to content

Instantly share code, notes, and snippets.

@tanner0101
Created June 13, 2016 02:39
Show Gist options
  • Save tanner0101/007a69f019796eb1f157ffc911d6aa7c to your computer and use it in GitHub Desktop.
Save tanner0101/007a69f019796eb1f157ffc911d6aa7c to your computer and use it in GitHub Desktop.
Rails Benchmark
class BenchmarkController < ActionController::Base
def plaintext
render plain: "Hello world"
end
def json
a = [1, 2, 3]
d = {"one" => 1, "two" => 2, "three" => 3}
r = {"array" => a, "dict" => d, "int" => 42, "string" => "test", "double" => 3.14, "null" => nil}
render :json => r
end
def sqlite
r = ActiveRecord::Base.connection.exec_query("SELECT * FROM users ORDER BY random() LIMIT 1")
render :json => r
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment