summaryrefslogtreecommitdiffhomepage
path: root/test/benchmark.rb
diff options
context:
space:
mode:
authorGeremia Taglialatela <[email protected]>2023-04-13 13:09:14 +0200
committerGeremia Taglialatela <[email protected]>2023-05-03 16:05:17 +0200
commite81036b76e734ab03fac31faafb9732f6b3b2928 (patch)
tree4a5944faddeac7aa574a26955d41f4901fccc038 /test/benchmark.rb
parent194e852d4f61d7c1acf4cd79df86bee43d84028a (diff)
downloadcaxlsx-e81036b76e734ab03fac31faafb9732f6b3b2928.tar.gz
caxlsx-e81036b76e734ab03fac31faafb9732f6b3b2928.zip
Fix offenses to non-production code
- Lint/AmbiguousBlockAssociation - Lint/AmbiguousOperatorPrecedence - Lint/EmptyBlock - Lint/RedundantSplatExpansion - Lint/RedundantStringCoercion - Lint/SymbolConversion - Lint/UnusedBlockArgument - Style/BlockDelimiters - Style/CommentAnnotation - Style/EachForSimpleLoop - Style/EmptyMethod - Style/ExpandPathArguments - Style/FileWrite - Style/GlobalStdStream (UNSAFE) - Style/HashEachMethods (UNSAFE) - Style/NestedParenthesizedCalls - Style/NilComparison - Style/NumericLiteralPrefix (manually fixed) - Style/ParallelAssignment - Style/PreferredHashMethods (UNSAFE) - Style/RedundantInterpolation (UNSAFE) - Style/RedundantParentheses (UNSAFE) - Style/RegexpLiteral - Style/RescueStandardError - Style/SpecialGlobalVars (UNSAFE) - Style/SymbolProc (UNSAFE) - Style/ZeroLengthPredicate (UNSAFE)
Diffstat (limited to 'test/benchmark.rb')
-rwxr-xr-x[-rw-r--r--]test/benchmark.rb25
1 files changed, 13 insertions, 12 deletions
diff --git a/test/benchmark.rb b/test/benchmark.rb
index 3c0ebc95..7cbffa32 100644..100755
--- a/test/benchmark.rb
+++ b/test/benchmark.rb
@@ -1,5 +1,6 @@
#!/usr/bin/env ruby -s
-$:.unshift "#{File.dirname(__FILE__)}/../lib"
+
+$LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../lib"
require 'axlsx'
require 'csv'
require 'benchmark'
@@ -9,7 +10,7 @@ input = (32..126).to_a.pack('U*').chars.to_a
20.times { row << input.shuffle.join }
times = 3000
Benchmark.bmbm(30) do |x|
- x.report('axlsx_noautowidth') {
+ x.report('axlsx_noautowidth') do
p = Axlsx::Package.new
p.workbook do |wb|
wb.add_worksheet do |sheet|
@@ -20,9 +21,9 @@ Benchmark.bmbm(30) do |x|
end
p.use_autowidth = false
p.serialize("example_noautowidth.xlsx")
- }
+ end
- x.report('axlsx') {
+ x.report('axlsx') do
p = Axlsx::Package.new
p.workbook do |wb|
wb.add_worksheet do |sheet|
@@ -32,9 +33,9 @@ Benchmark.bmbm(30) do |x|
end
end
p.serialize("example_autowidth.xlsx")
- }
+ end
- x.report('axlsx_shared') {
+ x.report('axlsx_shared') do
p = Axlsx::Package.new
p.workbook do |wb|
wb.add_worksheet do |sheet|
@@ -45,9 +46,9 @@ Benchmark.bmbm(30) do |x|
end
p.use_shared_strings = true
p.serialize("example_shared.xlsx")
- }
+ end
- x.report('axlsx_stream') {
+ x.report('axlsx_stream') do
p = Axlsx::Package.new
p.workbook do |wb|
wb.add_worksheet do |sheet|
@@ -57,15 +58,15 @@ Benchmark.bmbm(30) do |x|
end
end
s = p.to_stream()
- File.open('example_streamed.xlsx', 'wb') { |f| f.write(s.read) }
- }
+ File.binwrite('example_streamed.xlsx', s.read)
+ end
- x.report('csv') {
+ x.report('csv') do
CSV.open("example.csv", "wb") do |csv|
times.times do
csv << row
end
end
- }
+ end
end
File.delete("example.csv", "example_streamed.xlsx", "example_shared.xlsx", "example_autowidth.xlsx", "example_noautowidth.xlsx")