mirror of
https://github.com/1SecondEveryday/image-analysis-eval.git
synced 2026-03-25 09:05:49 +00:00
Add benchmark script
This commit is contained in:
parent
f2750ed0e2
commit
0d0e7a7cb0
1 changed files with 54 additions and 0 deletions
54
benchmark_parallel.rb
Executable file
54
benchmark_parallel.rb
Executable file
|
|
@ -0,0 +1,54 @@
|
|||
#!/usr/bin/env ruby
|
||||
|
||||
require 'fileutils'
|
||||
|
||||
# Test with a small subset
|
||||
test_sizes = [1, 2, 4, 8]
|
||||
test_model = ARGV[0] || 'moondream:1.8b'
|
||||
|
||||
puts "Benchmarking parallelism with model: #{test_model}"
|
||||
puts "This will resize some test images and run quick tests"
|
||||
puts "=" * 60
|
||||
|
||||
# Create test images if needed
|
||||
unless Dir.exist?('photo-512')
|
||||
puts "Creating test images..."
|
||||
system('./resize_images.rb')
|
||||
end
|
||||
|
||||
# Run tests with different parallelism levels
|
||||
results = {}
|
||||
|
||||
test_sizes.each do |parallel|
|
||||
puts "\nTesting with #{parallel} parallel requests..."
|
||||
|
||||
start_time = Time.now
|
||||
|
||||
# Run with just one prompt and limited images
|
||||
success = system(
|
||||
"./extract_tags.rb -p #{parallel} -m #{test_model} -v"
|
||||
out: File::NULL,
|
||||
err: File::NULL
|
||||
)
|
||||
|
||||
elapsed = Time.now - start_time
|
||||
results[parallel] = elapsed
|
||||
|
||||
puts " Time: #{elapsed.round(1)}s"
|
||||
|
||||
# Clean up results between runs
|
||||
FileUtils.rm_rf('results')
|
||||
end
|
||||
|
||||
puts "\n" + "=" * 60
|
||||
puts "RESULTS:"
|
||||
puts "=" * 60
|
||||
|
||||
baseline = results[1]
|
||||
results.each do |parallel, time|
|
||||
speedup = baseline / time
|
||||
puts "#{parallel} parallel: #{time.round(1)}s (#{speedup.round(2)}x speedup)"
|
||||
end
|
||||
|
||||
optimal = results.min_by { |_, time| time }
|
||||
puts "\nOptimal parallelism: #{optimal[0]} (#{optimal[1].round(1)}s)"
|
||||
Loading…
Reference in a new issue