Skip to content

Commit 585fe0b

Browse files
authored
feat: test execution time in nanoseconds (#1013)
1 parent d8bdeff commit 585fe0b

File tree

4 files changed

+14
-9
lines changed

4 files changed

+14
-9
lines changed

.changeset/tender-pillows-grab.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@nomicfoundation/edr": minor
3+
---
4+
5+
Changed test and test suite execution time from milliseconds to nanoseconds. Correspondingly, the `durationMs` property of `TestResult` and `SuiteResult` was renamed to `durationNs`.

crates/edr_napi/index.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1300,7 +1300,7 @@ export declare class SuiteResult {
13001300
*/
13011301
readonly id: ArtifactId
13021302
/** See [edr_solidity_tests::result::SuiteResult::duration] */
1303-
readonly durationMs: bigint
1303+
readonly durationNs: bigint
13041304
/** See [edr_solidity_tests::result::SuiteResult::test_results] */
13051305
readonly testResults: Array<TestResult>
13061306
/** See [edr_solidity_tests::result::SuiteResult::warnings] */
@@ -1321,7 +1321,7 @@ export declare class TestResult {
13211321
/** See [edr_solidity_tests::result::TestResult::kind] */
13221322
readonly kind: StandardTestKind | FuzzTestKind | InvariantTestKind
13231323
/** See [edr_solidity_tests::result::TestResult::duration] */
1324-
readonly durationMs: bigint
1324+
readonly durationNs: bigint
13251325
/**
13261326
* Compute the error stack trace.
13271327
* The result is either the stack trace or the reason why we couldn't

crates/edr_napi/src/solidity_tests/test_results.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ pub struct SuiteResult {
3232
pub id: ArtifactId,
3333
/// See [edr_solidity_tests::result::SuiteResult::duration]
3434
#[napi(readonly)]
35-
pub duration_ms: BigInt,
35+
pub duration_ns: BigInt,
3636
/// See [edr_solidity_tests::result::SuiteResult::test_results]
3737
#[napi(readonly)]
3838
pub test_results: Vec<TestResult>,
@@ -49,7 +49,7 @@ impl SuiteResult {
4949
) -> Self {
5050
Self {
5151
id: id.into(),
52-
duration_ms: BigInt::from(suite_result.duration.as_millis()),
52+
duration_ns: BigInt::from(suite_result.duration.as_nanos()),
5353
test_results: suite_result
5454
.test_results
5555
.into_iter()
@@ -84,7 +84,7 @@ pub struct TestResult {
8484
pub kind: Either3<StandardTestKind, FuzzTestKind, InvariantTestKind>,
8585
/// See [edr_solidity_tests::result::TestResult::duration]
8686
#[napi(readonly)]
87-
pub duration_ms: BigInt,
87+
pub duration_ns: BigInt,
8888

8989
stack_trace_result: Option<Arc<StackTraceResult<String>>>,
9090
call_trace_arenas: Vec<(traces::TraceKind, SparsedTraceArena)>,
@@ -263,7 +263,7 @@ impl TestResult {
263263
reverts: BigInt::from(reverts as u64),
264264
}),
265265
},
266-
duration_ms: BigInt::from(test_result.duration.as_millis()),
266+
duration_ns: BigInt::from(test_result.duration.as_nanos()),
267267
stack_trace_result: test_result.stack_trace_result.map(Arc::new),
268268
call_trace_arenas: if include_trace {
269269
test_result.traces

crates/tools/js/benchmark/src/solidity-tests.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,12 +94,12 @@ export async function runSolidityTests(
9494
throw new Error(`Didn't run any tests for ${repoPath}`);
9595
}
9696

97-
results.sort((a, b) => Number(a.durationMs - b.durationMs));
97+
results.sort((a, b) => Number(a.durationNs - b.durationNs));
9898
for (const result of results) {
99-
console.log(result.id.name, result.durationMs, result.id.source);
99+
console.log(result.id.name, result.durationNs / 1000000n, result.id.source);
100100
for (const test of result.testResults) {
101101
// @ts-ignore
102-
console.log(" ", test.name, test.durationMs, test.kind.runs);
102+
console.log(" ", test.name, test.durationNs / 1000000n, test.kind.runs);
103103
}
104104
}
105105

0 commit comments

Comments
 (0)