Skip to content

Commit

Permalink
add 1 million files sample
Browse files Browse the repository at this point in the history
  • Loading branch information
mamantoha committed Apr 25, 2024
1 parent df769f0 commit 8d2048c
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions samples/million.cr
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# https://github.com/crystal-lang/crystal/issues/14534
# No error with `Zip64`

require "../src/zip64"

dest = "out.zip"
ii = 0
begin
File.open(dest, "w") do |zipFile|

Check notice on line 9 in samples/million.cr

View workflow job for this annotation

GitHub Actions / Ameba

Naming/VariableNames

Var name should be underscore-cased: zip_file, not zipFile
Raw output
> File.open(dest, "w") do |zipFile|
                           ^
Zip64::Writer.open(zipFile) do |zip|

Check notice on line 10 in samples/million.cr

View workflow job for this annotation

GitHub Actions / Ameba

Naming/VariableNames

Var name should be underscore-cased: zip_file, not zipFile
Raw output
> Zip64::Writer.open(zipFile) do |zip|
                     ^
1000000.times do |i|
ii = i

max = 5 * 1024
totalBytes = Random.rand(100..max)

Check notice on line 15 in samples/million.cr

View workflow job for this annotation

GitHub Actions / Ameba

Naming/VariableNames

Var name should be underscore-cased: total_bytes, not totalBytes
Raw output
> totalBytes = Random.rand(100..max)
  ^
zip.add "file#{i}", Random.new.random_bytes(totalBytes)

Check notice on line 16 in samples/million.cr

View workflow job for this annotation

GitHub Actions / Ameba

Naming/VariableNames

Var name should be underscore-cased: total_bytes, not totalBytes
Raw output
> zip.add "file#{i}", Random.new.random_bytes(totalBytes)
                                              ^
end
end
end
rescue e
puts "## Failed adding file to zip on loop #{ii}: #{e.message}"
puts e.inspect_with_backtrace
end
puts "done"

0 comments on commit 8d2048c

Please sign in to comment.