Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

benchmarkable

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

benchmarkable

  • 1.0
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

BENCHMARKABLE by Aman King

http://bitbucket.org/amanking/benchmarkable/

A module that allows a class to mention which instance methods to benchmark, and then allows retrieving the benchmark report in csv format from the class's instances. The csv includes the method invocation timestamp, some context description (if provided), the method name along with arguments passed for the invocation, and the number of seconds the method took to execute.

Eg: class Gateway

...

def make_request(url) url = URI.parse(url) Net::HTTP.start(url.host, url.port) {|http| http.get('/index.html') } rescue => error puts "Unexpected error: #{error.message}" end

...

include Benchmarkable benchmark :make_request end

gateway = Gateway.new gateway.make_request('http://www.google.com/') gateway.make_request('http://www.yahoo.com/') gateway.make_request('http://www.wikyblog.com/AmanKing/') File.open('./gateway_performance_report.csv', 'a+') do |file| file.puts gateway.benchmark_report.to_csv(:starting_context => 'gateway') end

Output (in gateway_performance_report.csv): "2009-09-10T20:13:59+05:30","gateway","make_request http://www.google.com/","0.306514978408813" "2009-09-10T20:13:59+05:30","gateway","make_request http://www.yahoo.com/","1.08063411712646" "2009-09-10T20:14:00+05:30","gateway","make_request http://www.wikyblog.com/AmanKing/","2.1521680355072"

(see samples/ajaxy_blog_spec.rb for an example of how to use Benchmarkable to monitor ajax performance using selenium, and look at spec/benchmarkable_spec.rb for more details about the api)

License

Copyright 2009 Aman King

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

 http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

FAQs

Package last updated on 28 Mar 2010

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc