test-prof 1.3.0 → 1.3.1

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: '0678bc968a267ebeece00e12338f6408683140428ecdd041ece64c70e6bb91c0'
4
- data.tar.gz: 3ab5bc88b7b5dea557847f05a16d7fc3e4c6c9212115cd16984a56b7dd7b1737
3
+ metadata.gz: c81241143c4e7788e5fef3e5508534e878615a8e1b9e577a389d50da04cf445c
4
+ data.tar.gz: cd4d3ff2cee2cc93c569d8d25fa574653c8c9b29a1e67d97673b6e784e341146
5
5
  SHA512:
6
- metadata.gz: 5b32e7e689cef27e72ce5f7e65ca0463bae7b83dfcaf77eba17aa0cc9bae1b74d6223b6b141e805debb7640b74b75be34bf238a8f41cb3efaf0386929935d814
7
- data.tar.gz: 34200774bc30c39acc48109fbc5031fd8f48abb5f7175799a1e1bbfd7650a11a441c9ba63638bf186d78ef5cd15b7b33e64782c781a7f28bd43e43cb6d1e5588
6
+ metadata.gz: 812d6f7fd0672cd5a08f3812aafb60b677be8ae8131620ca13495ae9f79b6b23bac3b3a9cec1c1f64bc6c7cba4cae156baa5fb2441756bf21dc41e2bfe2c4b70
7
+ data.tar.gz: 6990de149f5824297ea8ff60ed07cc4ad8098fbb52a990d602418aaf37222a9a0583895ec2fa8c9a78fc6e54c8abadb344cdf53468e2f39daf900bbb54377352
data/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  ## master (unreleased)
4
4
 
5
+ ## 1.3.1 (2023-12-12)
6
+
7
+ - Add support for dumping FactoryProf results in JSON format. ([@uzushino][])
8
+
5
9
  ## 1.3.0 (2023-11-21)
6
10
 
7
11
  - Add Vernier integration. ([@palkan][])
@@ -376,3 +380,4 @@ See [changelog](https://github.com/test-prof/test-prof/blob/v0.8.0/CHANGELOG.md)
376
380
  [@peret]: https://github.com/peret
377
381
  [@bf4]: https://github.com/bf4
378
382
  [@Vankiru]: https://github.com/Vankiru
383
+ [@uzushino]: https://github.com/uzushino
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "test_prof/ext/float_duration"
4
+
5
+ module TestProf::FactoryProf
6
+ module Printers
7
+ module Json # :nodoc: all
8
+ class << self
9
+ using TestProf::FloatDuration
10
+ include TestProf::Logging
11
+
12
+ def dump(result, start_time:)
13
+ return log(:info, "No factories detected") if result.raw_stats == {}
14
+
15
+ outpath = TestProf.artifact_path("test-prof.result.json")
16
+ File.write(outpath, convert_stats(result, start_time).to_json)
17
+
18
+ log :info, "Profile results to JSON: #{outpath}"
19
+ end
20
+
21
+ def convert_stats(result, start_time)
22
+ total_run_time = TestProf.now - start_time
23
+ total_count = result.stats.sum { |stat| stat[:total_count] }
24
+ total_top_level_count = result.stats.sum { |stat| stat[:top_level_count] }
25
+ total_time = result.stats.sum { |stat| stat[:top_level_time] }
26
+ total_uniq_factories = result.stats.map { |stat| stat[:name] }.uniq.count
27
+
28
+ {
29
+ total_count: total_count,
30
+ total_top_level_count: total_top_level_count,
31
+ total_time: total_time.duration,
32
+ total_run_time: total_run_time.duration,
33
+ total_uniq_factories: total_uniq_factories,
34
+
35
+ stats: result.stats
36
+ }
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -3,6 +3,7 @@
3
3
  require "test_prof/factory_prof/printers/simple"
4
4
  require "test_prof/factory_prof/printers/flamegraph"
5
5
  require "test_prof/factory_prof/printers/nate_heckler"
6
+ require "test_prof/factory_prof/printers/json"
6
7
  require "test_prof/factory_prof/factory_builders/factory_bot"
7
8
  require "test_prof/factory_prof/factory_builders/fabrication"
8
9
 
@@ -25,6 +26,8 @@ module TestProf
25
26
  Printers::Flamegraph
26
27
  when "nate_heckler"
27
28
  Printers::NateHeckler
29
+ when "json"
30
+ Printers::Json
28
31
  else
29
32
  Printers::Simple
30
33
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TestProf
4
- VERSION = "1.3.0"
4
+ VERSION = "1.3.1"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: test-prof
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vladimir Dementyev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-11-21 00:00:00.000000000 Z
11
+ date: 2023-12-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -177,6 +177,7 @@ files:
177
177
  - lib/test_prof/factory_prof/factory_builders/factory_bot.rb
178
178
  - lib/test_prof/factory_prof/nate_heckler.rb
179
179
  - lib/test_prof/factory_prof/printers/flamegraph.rb
180
+ - lib/test_prof/factory_prof/printers/json.rb
180
181
  - lib/test_prof/factory_prof/printers/nate_heckler.rb
181
182
  - lib/test_prof/factory_prof/printers/simple.rb
182
183
  - lib/test_prof/logging.rb