Skip to content

Instantly share code, notes, and snippets.

@jackowayed
Created April 11, 2011 05:34
Show Gist options
  • Save jackowayed/913106 to your computer and use it in GitHub Desktop.
Save jackowayed/913106 to your computer and use it in GitHub Desktop.
Benchmarks your CS 107 assignment against the solution
#!/usr/bin/env ruby
require 'open3'
# Ruby doesn't realize how AFS works and is thus complaining about the
# executable it's running being world writable.
# It complains to stderr, so just suppress that.
$stderr.reopen('/dev/null', 'w')
def test(command)
a,b,stderr = Open3.popen3 command
stderr.read =~ /(\d+:\d+\.\d+)elapsed/
$1
end
ARGV.each do |file|
them = test "time /usr/class/cs107/samples/assign1/reassemble_soln #{file}"
us = test "time ./reassemble #{file}"
puts file, "them: #{them}", "us: #{us}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment