1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
// src/counters.rs
//! Unstable diagnostics. Outside semver: may change or disappear in any
//! release.
//!
//! Deterministic operation counters for performance tests. Compiled only
//! under the `unstable-counters` feature. Without it this module does not
//! exist, and every `count!` site in the crate expands to an empty block, so
//! a normal build carries no counter, no thread-local and no branch.
//!
//! # The mechanism
//!
//! One `Cell<u64>` per counter, in a `thread_local!`, incremented by the
//! crate's internal `count!` macro and **read by nothing in the library**: an
//! operation that consulted its own counters would behave differently
//! depending on what ran before it.
//!
//! **A count covers only work done on the calling thread.** [`snapshot`] and
//! [`reset`] read and zero the calling thread's counters and no other's. No
//! operation in this crate spawns a thread, so an operation's whole count
//! lands on the thread that called it, and two tests running in parallel on
//! two threads cannot see each other's counts. A test that reads them resets,
//! runs one operation and snapshots, on one thread; it needs no lock and no
//! `--test-threads=1`.
//!
//! `arithmetica`'s adaptive-ladder counters are a separate mechanism in that
//! crate. A test that reads them depends on `arithmetica` directly, with its
//! `stage-counters` feature; they are process-global, so such a test still
//! runs alone.
//!
//! # The counters
//!
//! | Counter | Counts |
//! |---|---|
//! | `ring_edge_classifications` | ring edges of one areal operand classified against the other in the DE-9IM areal analysis |
//! | `prepared_early_outs` | prepared `relate` calls decided by the envelope early-out |
//! | `prepared_delegations` | prepared `relate` calls that ran the unprepared operation |
//! | `delaunay_orient_calls` | `orient2d` calls made by `ops::delaunay` (walks, ghost tests, collinearity, output certification) |
//! | `delaunay_incircle_calls` | `incircle` calls made by `ops::delaunay` (cavity tests and the canonicalization pass) |
//! | `coverage_simplify_veto_checks` | removals `ops::coverage_simplify` put to its exact topology checks |
//! | `coverage_simplify_veto_rejections` | of those, the removals the checks rejected |
//! | `coverage_simplify_index_updates` | segment insertions and removals in `ops::coverage_simplify`'s dynamic index |
//! | `coverage_simplify_index_queries` | candidate queries `ops::coverage_simplify` made of that index |
use Cell;
/// Defines the counter set once: the thread-local block, its snapshot type,
/// and the read and reset functions, so a counter cannot be added to one and
/// forgotten in another.
thread_local!
/// A copy of every counter of the calling thread at one moment.
/// Reads every counter of the calling thread.
/// Zeroes every counter of the calling thread.
};
}
define_counters!
/// Adds `n` to one counter of the calling thread. Crate-internal; used only
/// by the `count!` macro. Wrapping, as the atomic counters it replaces were.
pub