mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-10-29 17:50:22 +00:00
Allow for result to be generated when there are un-committed changes.
This commit is contained in:
12
Rakefile
12
Rakefile
@@ -26,10 +26,11 @@ end
|
|||||||
namespace :benchmark do
|
namespace :benchmark do
|
||||||
benchmark_path = "benchmark/results"
|
benchmark_path = "benchmark/results"
|
||||||
|
|
||||||
# $ rake benchmark:generate CORPUS=path/to/samples
|
# $ bundle exec rake benchmark:generate CORPUS=path/to/samples
|
||||||
desc "Generate results for"
|
desc "Generate results for"
|
||||||
task :generate do
|
task :generate do
|
||||||
ref = `git rev-parse HEAD`.strip[0,8]
|
ref = `git rev-parse HEAD`.strip[0,8]
|
||||||
|
|
||||||
corpus = File.expand_path(ENV["CORPUS"] || "samples")
|
corpus = File.expand_path(ENV["CORPUS"] || "samples")
|
||||||
|
|
||||||
require 'linguist/language'
|
require 'linguist/language'
|
||||||
@@ -45,12 +46,17 @@ namespace :benchmark do
|
|||||||
FileUtils.mkdir_p("benchmark/results")
|
FileUtils.mkdir_p("benchmark/results")
|
||||||
|
|
||||||
# Write results
|
# Write results
|
||||||
result_filename = "benchmark/results/#{File.basename(corpus)}-#{ref}.json"
|
if `git status`.include?('working directory clean')
|
||||||
|
result_filename = "benchmark/results/#{File.basename(corpus)}-#{ref}.json"
|
||||||
|
else
|
||||||
|
result_filename = "benchmark/results/#{File.basename(corpus)}-#{ref}-unstaged.json"
|
||||||
|
end
|
||||||
|
|
||||||
File.write(result_filename, results.to_json)
|
File.write(result_filename, results.to_json)
|
||||||
puts "wrote #{result_filename}"
|
puts "wrote #{result_filename}"
|
||||||
end
|
end
|
||||||
|
|
||||||
# $ rake benchmark:compare REFERENCE=path/to/reference.json CANDIDATE=path/to/candidate.json
|
# $ bundle exec rake benchmark:compare REFERENCE=path/to/reference.json CANDIDATE=path/to/candidate.json
|
||||||
desc "Compare results"
|
desc "Compare results"
|
||||||
task :compare do
|
task :compare do
|
||||||
reference_file = ENV["REFERENCE"]
|
reference_file = ENV["REFERENCE"]
|
||||||
|
|||||||
Reference in New Issue
Block a user