Skip to content

Commit f4620d4

Browse files
committed
+ tps_prof updates
1 parent 76be7f9 commit f4620d4

1 file changed

Lines changed: 28 additions & 1 deletion

File tree

docs/guide/profilers/tps_prof.md

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# TPSProf
22

3-
@available_since version=1.6.0
3+
@available_since version=1.6.0
44

55
TPSProf measures tests-per-second (TPS) for your top-level example groups and helps identify the slowest ones. It can also run in **strict mode** to fail the build when groups fall below a TPS threshold.
66

@@ -110,3 +110,30 @@ TestProf::TPSProf.configure do |config|
110110
config.min_tps = 5
111111
end
112112
```
113+
114+
### Custom strict handler
115+
116+
You can provide a custom strict handler to implement your own violation logic. The handler receives a `GroupInfo` object with the following attributes: `group`, `location`, `examples_count`, `total_time`, `tps`, and `penalty`. Raise an exception to mark the group as a violation. Here is an example configuration to use different TPS thresholds for different test types:
117+
118+
```ruby
119+
TestProf::TPSProf.configure do |config|
120+
config.mode = :strict
121+
config.strict_handler = ->(group_info) {
122+
if group_info.group.metadata[:type] == :system
123+
raise "Group #{group_info.location} is too slow: #{group_info.tps} TPS" if group_info.tps < 5
124+
else
125+
raise "Group #{group_info.location} is too slow: #{group_info.tps} TPS" if group_info.tps < 20
126+
end
127+
}
128+
end
129+
```
130+
131+
## Ignoring groups and examples
132+
133+
You can exclude specific groups from TPSProf tracking using the `tps_prof: :ignore` metadata:
134+
135+
```ruby
136+
RSpec.describe "SlowButOk", tps_prof: :ignore do
137+
# ...
138+
end
139+
```

0 commit comments

Comments
 (0)