@@ -15,11 +15,11 @@ pub struct ProfilerFiles {
15
15
}
16
16
17
17
impl ProfilerFiles {
18
- pub fn new ( path_stem : & Path ) -> ProfilerFiles {
18
+ pub fn new < P : AsRef < Path > > ( path_stem : P ) -> ProfilerFiles {
19
19
ProfilerFiles {
20
- events_file : path_stem. with_extension ( "events" ) ,
21
- string_data_file : path_stem. with_extension ( "string_data" ) ,
22
- string_index_file : path_stem. with_extension ( "string_index" ) ,
20
+ events_file : path_stem. as_ref ( ) . with_extension ( "events" ) ,
21
+ string_data_file : path_stem. as_ref ( ) . with_extension ( "string_data" ) ,
22
+ string_index_file : path_stem. as_ref ( ) . with_extension ( "string_index" ) ,
23
23
}
24
24
}
25
25
}
@@ -31,8 +31,9 @@ pub struct Profiler<S: SerializationSink> {
31
31
}
32
32
33
33
impl < S : SerializationSink > Profiler < S > {
34
- pub fn new ( path_stem : & Path ) -> Result < Profiler < S > , Box < dyn Error > > {
35
- let paths = ProfilerFiles :: new ( path_stem) ;
34
+ pub fn new < P : AsRef < Path > > ( path_stem : P )
35
+ -> Result < Profiler < S > , Box < dyn Error + Send + Sync > > {
36
+ let paths = ProfilerFiles :: new ( path_stem. as_ref ( ) ) ;
36
37
let event_sink = Arc :: new ( S :: from_path ( & paths. events_file ) ?) ;
37
38
38
39
// The first thing in every file we generate must be the file header.
@@ -126,8 +127,7 @@ impl<S: SerializationSink> Profiler<S> {
126
127
}
127
128
128
129
fn nanos_since_start ( & self ) -> u64 {
129
- let duration_since_start = self . start_time . elapsed ( ) ;
130
- duration_since_start. as_secs ( ) * 1_000_000_000 + duration_since_start. subsec_nanos ( ) as u64
130
+ self . start_time . elapsed ( ) . as_nanos ( ) as _
131
131
}
132
132
}
133
133
0 commit comments