Skip to content

Commit

Permalink
Benchmark example1-seqnos.aln in addition to example1.aln
Browse files Browse the repository at this point in the history
 * sample/benchmark_clustalw_report.rb: Benchmark parsing speed of
   example1-seqnos.aln in addition to example1.aln.
  • Loading branch information
ngoto committed Nov 23, 2013
1 parent c5d3e76 commit 1f829ae
Showing 1 changed file with 22 additions and 6 deletions.
28 changes: 22 additions & 6 deletions sample/benchmark_clustalw_report.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,36 @@
require 'benchmark'
require 'bio'

module BenchmarkClustalWReport
class BenchmarkClustalWReport

DataDir = File.join(BioRubyTestDataPath, 'clustalw')
Filenames = [ 'example1.aln', 'example1-seqnos.aln' ]

def self.benchmark_clustalw_report
Filenames.each do |fn|
print "\n", fn, "\n"
fullpath = File.join(DataDir, fn)
self.new(fullpath).benchmark
end
end

def initialize(aln_filename)
@text = File.open(aln_filename, 'rb') { |f| f.read }
@text.freeze
end

def benchmark
GC.start
Benchmark.bmbm do |x|
test_data_path = Pathname.new(File.join(BioRubyTestDataPath, 'clustalw')).cleanpath.to_s
aln_filename = File.join(test_data_path, 'example1.aln')
text = File.read(aln_filename)
x.report do
for i in 1...10_000
aln = Bio::ClustalW::Report.new(text)
aln = Bio::ClustalW::Report.new(@text)
aln.alignment
end
end
end
end
end

end #class BenchmarkClustalWReport

BenchmarkClustalWReport.benchmark_clustalw_report

0 comments on commit 1f829ae

Please sign in to comment.