
Security News
Follow-up and Clarification on Recent Malicious Ruby Gems Campaign
A clarification on our recent research investigating 60 malicious Ruby gems.
== bench
== DESCRIPTION
Do you remeber how to use the benchmark library from the Ruby standard lib? I don't.
Now you need not to remember, there is Bench: A DSL around the benchmark lib of the Ruby standard lib with the goal to make benchmarking as easy as possible.'
== SYNOPSIS
First an adapted example of the benchmark documentation from the pickaxe version 2 page 657
require 'bench'
string = 'Stormy Weather' m = string.method(:length)
benchmark 'code' do m.call end
benchmark 'send' do string.send(:length) end
benchmark 'eval' do eval "string.length" end
run 10_000
You call the run method more than once for identifying rought values.
It's also nice to use Bench interactive with irb:
require 'bench' => true benchmark 'simple' do ?> /ll/ =~ 'hello world' end => [#<OpenStruct name="simple", proc=#Proc:0xb7bf7acc@(irb):2] benchmark 'freezed' do ?> /ll/.freeze =~ 'hello world' end => [#<OpenStruct name="simple", proc=#Proc:0xb7bf7acc@(irb):2, #<OpenStruct na me="freezed", proc=#Proc:0xb7bf26d0@(irb):5] run 1000 user system total real simple 0.000000 0.000000 0.000000 ( 0.003960) freezed 0.010000 0.000000 0.010000 ( 0.004870) => true run 1000 user system total real simple 0.010000 0.000000 0.010000 ( 0.003969) freezed 0.000000 0.000000 0.000000 ( 0.004624) => true
let's try more iterations
?> run 10000 user system total real simple 0.060000 0.000000 0.060000 ( 0.058049) freezed 0.060000 0.000000 0.060000 ( 0.058636) => true
run 100000 user system total real simple 0.500000 0.000000 0.500000 ( 0.502427) freezed 0.540000 0.000000 0.540000 ( 0.533421) => true
now another benchmark sample
?> RE = /ll/ => ll
benchmark 'constant' do ?> RE =~ 'hello world' end => [#<OpenStruct name="simple", proc=#Proc:0xb7bf7acc@(irb):2, #<OpenStruct name="freezed", proc=#Proc:0xb7bf26d0@(irb):5, #<OpenStruct name="constant", proc=#Proc:0xb7c26250@(irb):15] run user system total real simple 0.000000 0.000000 0.000000 ( 0.000031) freezed 0.000000 0.000000 0.000000 ( 0.000469) constant 0.000000 0.000000 0.000000 ( 0.000031) => true run 100000 user system total real simple 0.500000 0.000000 0.500000 ( 0.507686) freezed 0.540000 0.000000 0.540000 ( 0.537840) constant 0.550000 0.000000 0.550000 ( 0.552103) => true run 100000 user system total real simple 0.510000 0.000000 0.510000 ( 0.506002) freezed 0.520000 0.000000 0.520000 ( 0.542898) constant 0.520000 0.020000 0.540000 ( 0.552802) => true run 100000 user system total real simple 0.510000 0.000000 0.510000 ( 0.504704) freezed 0.530000 0.000000 0.530000 ( 0.536948) constant 0.560000 0.000000 0.560000 ( 0.554470) => true
== CREDITS
Copyright 2008 by Jan Friedrich (janfri.rubyforge@gmail.com)
== LICENSE
Ruby's license.
FAQs
Unknown package
We found that bench demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
A clarification on our recent research investigating 60 malicious Ruby gems.
Security News
ESLint now supports parallel linting with a new --concurrency flag, delivering major speed gains and closing a 10-year-old feature request.
Research
/Security News
A malicious Go module posing as an SSH brute forcer exfiltrates stolen credentials to a Telegram bot controlled by a Russian-speaking threat actor.