Skip to content

Commit a03f4dd

Browse files
committed
fixup: use hash rather than static counter
1 parent 563e79d commit a03f4dd

File tree

2 files changed

+119
-119
lines changed

2 files changed

+119
-119
lines changed

go-runner/src/builder/discovery.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
//! Finds all the benchmarks and packages in a given Go project.
22
33
use std::{
4+
hash::{DefaultHasher, Hash, Hasher},
45
ops::Deref,
56
path::{Path, PathBuf},
67
process::Command,
7-
sync::atomic::{AtomicU32, Ordering},
88
};
99

1010
use crate::builder::verifier;
@@ -200,13 +200,13 @@ pub struct GoBenchmark {
200200

201201
impl GoBenchmark {
202202
pub fn new(package_import_path: String, name: String, file_path: PathBuf) -> Self {
203-
static COUNTER: AtomicU32 = AtomicU32::new(0);
203+
let hash = {
204+
let mut hasher = DefaultHasher::new();
205+
package_import_path.hash(&mut hasher);
206+
hasher.finish()
207+
};
204208

205-
let import_alias = format!(
206-
"{}_{}",
207-
name.to_lowercase(),
208-
COUNTER.fetch_add(1, Ordering::Relaxed)
209-
);
209+
let import_alias = format!("{}_{}", name.to_lowercase(), hash);
210210
let qualified_name = format!("{}.{}", import_alias, &name);
211211
Self {
212212
module_path: package_import_path,

0 commit comments

Comments
 (0)