aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAria <me@aria.rip>2023-11-30 15:15:06 +0000
committerAria <me@aria.rip>2023-11-30 15:15:06 +0000
commite1a0a2f4f0d1ed88335dac157944d9460fc441de (patch)
treebecd0179cf7362ec425da37b00456b518bac219a
parent58f60ebdfeed194ef7c3eb2ea7b1622c1d509ea0 (diff)
fix(profiler): make profilerwrapper output to specific directory
-rw-r--r--src/crates/library/src/profiler.rs16
1 files changed, 7 insertions, 9 deletions
diff --git a/src/crates/library/src/profiler.rs b/src/crates/library/src/profiler.rs
index 214a376..c5280bd 100644
--- a/src/crates/library/src/profiler.rs
+++ b/src/crates/library/src/profiler.rs
@@ -1,4 +1,4 @@
-use std::{backtrace::Backtrace, fs::File, io::Write, time::SystemTime};
+use std::{backtrace::Backtrace, env::var, fs::File, io::Write, time::SystemTime};
use crate::traits::{Container, Indexable, Stack};
@@ -106,14 +106,12 @@ impl<T: Stack<E> + Container<E>, E> Stack<E> for ProfilerWrapper<T> {
impl<T> Drop for ProfilerWrapper<T> {
fn drop(&mut self) {
- let mut f = File::create(format!(
- "/tmp/candelabra-profile-{}",
- SystemTime::now()
- .duration_since(SystemTime::UNIX_EPOCH)
- .unwrap()
- .as_millis()
- ))
- .unwrap();
+ let base_dir =
+ var("PROFILER_OUT_DIR").expect("ProfilerWrapper used without environment variable");
+ let unix_time = SystemTime::now()
+ .duration_since(SystemTime::UNIX_EPOCH)
+ .unwrap();
+ let mut f = File::create(format!("{}/{}", base_dir, unix_time.as_nanos())).unwrap();
writeln!(f, "{}", self.sum_ns).unwrap();
writeln!(f, "{}", self.n_contains).unwrap();