mirror of
https://github.com/facebook/sapling.git
synced 2024-10-10 00:45:18 +03:00
542d1f93d3
Summary: This commit manually synchronizes the internal move of fbcode/scm/mononoke under fbcode/eden/mononoke which couldn't be performed by ShipIt automatically. Reviewed By: StanislavGlebik Differential Revision: D19722832 fbshipit-source-id: 52fbc8bc42a8940b39872dfb8b00ce9c0f6b0800
48 lines
1.1 KiB
Rust
48 lines
1.1 KiB
Rust
/*
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*
|
|
* This software may be used and distributed according to the terms of the
|
|
* GNU General Public License version 2.
|
|
*/
|
|
|
|
use std::sync::Arc;
|
|
use std::thread;
|
|
|
|
use chrono::Local;
|
|
use context::{PerfCounterType, PerfCounters};
|
|
|
|
fn main() {
|
|
let ctrs = Arc::new(PerfCounters::default());
|
|
let k = PerfCounterType::BlobGets;
|
|
let k2 = PerfCounterType::BlobPuts;
|
|
|
|
let start = Local::now();
|
|
println!("Start: {}", start);
|
|
|
|
let n_threads = 10;
|
|
let n_ops = 100000;
|
|
|
|
let threads = (0..n_threads).map(|_| {
|
|
thread::spawn({
|
|
let ctrs = ctrs.clone();
|
|
move || {
|
|
for i in 0..n_ops {
|
|
ctrs.increment_counter(k);
|
|
ctrs.set_max_counter(k2, i);
|
|
}
|
|
}
|
|
})
|
|
});
|
|
|
|
for t in threads {
|
|
t.join().unwrap();
|
|
}
|
|
|
|
let done = Local::now();
|
|
|
|
assert_eq!(ctrs.get_counter(k), n_threads * n_ops);
|
|
assert_eq!(ctrs.get_counter(k2), n_ops - 1);
|
|
|
|
println!("Elapsed: {}ms", (done - start).num_milliseconds());
|
|
}
|