benchmark-sweet 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0664b6e861a5c1627554264b942f758c6be5c5168f61fb86592a093b67818021
4
- data.tar.gz: ed985db22ce7b3a7e6df81d1e3b1cb2e6216b869ef1c1e36f1f9ca55a1d9b187
3
+ metadata.gz: d244cd69d99d599b4c6b7ae175ebcfa59b1c826ef66f643662bac4424d884f1b
4
+ data.tar.gz: 8350da53d68b067996858b52bdfbd5b9e7525d88042d099f0d68d443a00dc3c6
5
5
  SHA512:
6
- metadata.gz: c910b55cbf76d5b145ccef4c48b833c3baae48f3e36d6ee91ca902f2927124ebca4b58f6237a6fc44fc2e035bc80da60709006ff0a48eace348d810c96d36dd8
7
- data.tar.gz: 797ec9ed5b8ee09fa28f3325df1e4386cc0a4df3b739c06ed7cdc822bf149bf6d63953ca6b037c901524e7593f780483cdf04a0048535cfbeab1d047c9197d97
6
+ metadata.gz: 129add152f798180f6d7f3d76c294b7a8c78e8aa917a7c838c713a2177d339d3396b9155e0a253b96643207366e20377d9c61c219dc7f9088b0708356fa628c4
7
+ data.tar.gz: d618214ba5e14cf06c6c1ae323e7836514af96ebd39602fbf1c682be091ee8e20f1f755bc70a0756adddcddf3e4e5a794c45b14c2ce8a2ce8bdaac4933913de3
@@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
11
11
  ### Changed
12
12
 
13
13
  ### Fixed
14
+ - properly indent tables with iso color codes (thanks @d-m-u)
14
15
 
15
16
  ## [0.2.1] - 2020-06-24
16
17
 
@@ -37,6 +38,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
37
38
  ### Added
38
39
  - good stuff
39
40
 
40
- [Unreleased]: https://github.com/kbrock/benchmark-sweet/compare/v0.2.1...HEAD
41
+ [Unreleased]: https://github.com/kbrock/benchmark-sweet/compare/v0.2.2...HEAD
42
+ [0.2.2]: https://github.com/kbrock/benchmark-sweet/compare/v0.2.1...v0.2.2
41
43
  [0.2.1]: https://github.com/kbrock/benchmark-sweet/compare/v0.2.0...v0.2.1
42
44
  [0.2.0]: https://github.com/kbrock/benchmark-sweet/compare/v0.0.1...v0.2.0
data/README.md CHANGED
@@ -1,12 +1,12 @@
1
1
  # Benchmark::Sweet
2
2
 
3
- Time tends not to be consistent across multiple runs. But numbers of queries or the number of objects allocated tend to be more similar.
3
+ Time tends not to be consistent across multiple runs, but numbers of queries or the number of objects allocated tend to be more similar.
4
4
 
5
5
  This gem allows the user to collect all three of these benchmarks using a single framework similar to the benchmark and benchmark-ips syntax.
6
6
 
7
7
  Sometimes a benchmark needs to be collected across multiple runs using different gem versions or using different ruby versions. This can be done as well.
8
8
 
9
- Lastly, this allows multiple axes of comparisons to be performed. Example: instead of measuring multiple split implementations, it allows measuring these implementations using empty strings and long strings oo a bigger picture can be obtained.
9
+ Lastly, this allows multiple axes of comparisons to be performed. Example: instead of measuring multiple split implementations, it allows measuring these implementations using empty strings and long strings so a bigger picture can be obtained.
10
10
 
11
11
  ## Installation
12
12
 
@@ -31,7 +31,6 @@ Or install it yourself as:
31
31
  ```ruby
32
32
  require "benchmark/sweet"
33
33
  require "active_support/all"
34
- require "more_core_extensions/all" # [].tabelize
35
34
 
36
35
  NSTRING = nil
37
36
  DELIMITER='/'.freeze
@@ -107,7 +106,6 @@ This is not a native value, it is specified when the items are specified (e.g.:`
107
106
  ```ruby
108
107
  require "benchmark/sweet"
109
108
  require "active_support/all"
110
- require "more_core_extensions/all" # [].tabelize
111
109
 
112
110
  NSTRING = nil
113
111
  DELIMITER='/'.freeze
@@ -43,6 +43,5 @@ EOF
43
43
 
44
44
  spec.add_runtime_dependency "benchmark-ips", "~> 2.8.2"
45
45
  spec.add_runtime_dependency "memory_profiler", "~> 0.9.0"
46
- spec.add_runtime_dependency "more_core_extensions" # for [].tabelize - want to remove
47
46
  spec.add_runtime_dependency "activesupport" # for {}.symbolize_keys! - want to remove
48
47
  end
@@ -1,6 +1,5 @@
1
1
  require "benchmark/sweet"
2
2
  require "active_support/all"
3
- require "more_core_extensions/all" # [].tabelize
4
3
 
5
4
  # output:
6
5
  #
@@ -1,6 +1,5 @@
1
1
  require 'benchmark/sweet'
2
2
  require 'active_support/all'
3
- require "more_core_extensions/all" # [].tabelize
4
3
 
5
4
  # version 2.3.7
6
5
  #
@@ -1,6 +1,5 @@
1
1
  require "benchmark/sweet"
2
2
  require "active_support/all"
3
- require "more_core_extensions/all" # [].tabelize
4
3
 
5
4
  # method | NIL | EMPTY | FULL
6
5
  # --------------------+------------------------+------------------------+------------------------
@@ -1,5 +1,4 @@
1
1
  require "benchmark/sweet"
2
- require "more_core_extensions/all"
3
2
  require "active_record"
4
3
 
5
4
  # For various versions of rails, compare `Model.all.first` vs `Model.all.to_a.first`
@@ -1,5 +1,4 @@
1
1
  require "benchmark/sweet"
2
- require "more_core_extensions/all"
3
2
  require "active_record"
4
3
  #
5
4
  # label | ips | queries | rows
@@ -84,10 +84,28 @@ module Benchmark
84
84
  end
85
85
 
86
86
  def self.print_table(header_name, header_value, table_rows)
87
- require "more_core_extensions" # defines tableize
88
87
  puts "", "#{header_name} #{header_value}", "" if header_value
89
- # passing colummns to make sure table keeps the same column order
90
- puts table_rows.tableize(:columns => table_rows.first.keys)
88
+ to_table(table_rows)
89
+ end
90
+
91
+ def self.to_table(arr)
92
+ field_sizes = Hash.new
93
+ arr.each { |row| field_sizes.merge!(row => row.map { |iterand| iterand[1].to_s.gsub(/\e\[[^m]+m/, '').length } ) }
94
+
95
+ column_sizes = arr.reduce([]) do |lengths, row|
96
+ row.each_with_index.map { |iterand, index| [lengths[index] || 0, field_sizes[row][index]].max }
97
+ end
98
+
99
+ format = column_sizes.collect {|n| "%#{n}s" }.join(" | ")
100
+ format += "\n"
101
+
102
+ printf format, *arr[0].each_with_index.map { |el, i| " "*(column_sizes[i] - field_sizes[arr[0]][i] ) + el[0].to_s }
103
+
104
+ printf format, *column_sizes.collect { |w| "-" * w }
105
+
106
+ arr[0..arr.count].each do |line|
107
+ printf format, *line.each_with_index.map { |el, i| " "*(column_sizes[i] - field_sizes[line][i] ) + el[1].to_s }
108
+ end
91
109
  end
92
110
  end
93
111
  extend Benchmark::Sweet
@@ -1,5 +1,5 @@
1
1
  module Benchmark
2
2
  module Sweet
3
- VERSION = "0.2.1"
3
+ VERSION = "0.2.2"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: benchmark-sweet
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Keenan Brock
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-06-25 00:00:00.000000000 Z
11
+ date: 2020-07-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -94,20 +94,6 @@ dependencies:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
96
  version: 0.9.0
97
- - !ruby/object:Gem::Dependency
98
- name: more_core_extensions
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - ">="
102
- - !ruby/object:Gem::Version
103
- version: '0'
104
- type: :runtime
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - ">="
109
- - !ruby/object:Gem::Version
110
- version: '0'
111
97
  - !ruby/object:Gem::Dependency
112
98
  name: activesupport
113
99
  requirement: !ruby/object:Gem::Requirement