Skip to content

Instantly share code, notes, and snippets.

@joncooper
Created October 4, 2011 20:35
Show Gist options
  • Select an option

  • Save joncooper/1262716 to your computer and use it in GitHub Desktop.

Select an option

Save joncooper/1262716 to your computer and use it in GitHub Desktop.
Explorations in Go: A dupe checker in Go and Ruby #2
➜ dupe git:(master) time ./dupe ~
Total duped files found: 49432
./dupe ~ 6.73s user 16.67s system 77% cpu 30.309 total
➜ dupe git:(master) time ./dupe ~
Total duped files found: 49432
./dupe ~ 6.74s user 16.95s system 77% cpu 30.564 total
➜ dupe git:(master) time ./dupe ~
Total duped files found: 49432
./dupe ~ 6.70s user 16.85s system 77% cpu 30.423 total
➜ dupe git:(master) time ruby dupe.rb ~
Total duped files found: 49326
ruby dupe.rb ~ 10.70s user 20.32s system 81% cpu 38.042 total
➜ dupe git:(master) time ruby dupe.rb ~
Total duped files found: 49326
ruby dupe.rb ~ 10.69s user 20.34s system 80% cpu 38.660 total
➜ dupe git:(master) time ruby dupe.rb ~
Total duped files found: 49326
ruby dupe.rb ~ 10.86s user 21.47s system 74% cpu 43.27
Go: 30.432 sec
Ruby: 39.991 sec
@full_paths_by_filename.select! { |filename, fullpaths| fullpaths.length >= 2 }
func PrintResults() {
dupes := 0
for key, value := range fullPathsByFilename {
if (len(value) < 2) {
continue
}
dupes++
if (*verbose) {
println(key, ":")
for _, filename := range value {
println(" ", filename)
fmt.Printf(" %x\n", MD5OfFile(filename))
}
}
}
println("Total duped files found:", dupes)
}
def print_results
@full_paths_by_filename.select! { |filename, fullpaths| fullpaths.length >= 2 }
if (VERBOSE)
@full_paths_by_filename.each do |filename, fullpaths|
puts "#{filename}:"
for path in fullpaths do
puts " #{path}"
puts " #{md5_of_file(path)}"
end
end
end
puts "Total duped files found: #{@full_paths_by_filename.length}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment