Skip to content

Commit 756df3a

Browse files
andjo403michaelwoerister
authored andcommitted
break out read part of measureme to the tools_lib
1 parent c9d0caa commit 756df3a

File tree

18 files changed

+53
-53
lines changed

18 files changed

+53
-53
lines changed

crox/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ edition = "2018"
66

77
[dependencies]
88
measureme = { "path" = "../measureme" }
9+
tools_lib = { path = "../tools_lib" }
910
rustc-hash = "1.0.1"
1011
serde = { version = "1.0", features = [ "derive" ] }
1112
serde_json = "1.0"

crox/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use std::path::PathBuf;
55
use std::time::Duration;
66
use std::time::SystemTime;
77

8-
use measureme::{ProfilingData, Timestamp};
8+
use tools_lib::{ProfilingData, Timestamp};
99

1010
use serde::{Serialize, Serializer};
1111
use std::cmp;

flamegraph/src/main.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,9 @@ use std::fs::File;
33
use std::io::BufWriter;
44
use std::path::PathBuf;
55

6-
use measureme::ProfilingData;
7-
8-
use structopt::StructOpt;
9-
10-
use tools_lib::stack_collapse::collapse_stacks;
11-
126
use inferno::flamegraph::{from_lines, Options as FlamegraphOptions};
7+
use structopt::StructOpt;
8+
use tools_lib::{collapse_stacks, ProfilingData};
139

1410
#[derive(StructOpt, Debug)]
1511
struct Opt {

measureme/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,6 @@ rustc-hash = "1.0.1"
1818

1919
[target.'cfg(not(target_arch="wasm32"))'.dependencies]
2020
memmap = "0.6.0"
21+
22+
[dev-dependencies]
23+
tools_lib = { path = "../tools_lib" }

measureme/src/lib.rs

Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
//! This crate provides a library for high-performance event tracing which is used by the Rust compiler's unstable `-Z self-profile` feature.
2-
//!
3-
//! There are two main parts to this library:
4-
//! - Writing event trace files
5-
//! - Reading event trace files
1+
//! This crate provides a library for high-performance event tracing which is used by
2+
//! the Rust compiler's unstable `-Z self-profile` feature.
63
//!
74
//! The output of a tracing session will be three files:
85
//! 1. A `.events` file which contains all of the traced events.
@@ -13,7 +10,8 @@
1310
//!
1411
//! The main entry point for writing event trace files is the [`Profiler`] struct.
1512
//!
16-
//! To create a [`Profiler`], call the [`Profiler::new()`] function and provide a `Path` with the directory and file name for the trace files.
13+
//! To create a [`Profiler`], call the [`Profiler::new()`] function and provide a `Path` with
14+
//! the directory and file name for the trace files.
1715
//!
1816
//! To record an event, call the [`Profiler::record_event()`] method, passing a few arguments:
1917
//! - `event_kind`: a [`StringId`] which assigns an arbitrary category to the event
@@ -30,51 +28,33 @@
3028
//! - [`Profiler::alloc_string_with_reserved_id()`]: allocates a string using the specified [`StringId`].
3129
//! It is up to the caller to make sure the specified [`StringId`] hasn't already been used.
3230
//!
33-
//! # Reading event trace files
34-
//!
35-
//! The main entry point for reading trace files is the [`ProfilingData`] struct.
36-
//!
37-
//! To create a [`ProfilingData`], call the [`ProfilingData::new()`] function and provide a `Path` with the directory and file name for the trace files.
38-
//!
39-
//! To retrieve an `Iterator` of all of the events in the file, call the [`ProfilingData::iter()`] method.
40-
//!
41-
//! To retrieve an `Iterator` of only matching start/stop events, call the [`ProfilingData::iter_matching_events()`] method.
42-
//!
4331
//! [`Profiler`]: struct.Profiler.html
4432
//! [`Profiler::alloc_string()`]: struct.Profiler.html#method.alloc_string
4533
//! [`Profiler::alloc_string_with_reserved_id()`]: struct.Profiler.html#method.alloc_string_with_reserved_id
4634
//! [`Profiler::new()`]: struct.Profiler.html#method.new
4735
//! [`Profiler::record_event()`]: struct.Profiler.html#method.record_event
4836
//! [`Profiler::start_recording_interval_event()`]: struct.Profiler.html#method.start_recording_interval_event
49-
//! [`ProfilingData`]: struct.ProfilingData.html
50-
//! [`ProfilingData::iter()`]: struct.ProfilingData.html#method.iter
51-
//! [`ProfilingData::iter_matching_events()`]: struct.ProfilingData.html#method.iter_matching_events
5237
//! [`StringId`]: struct.StringId.html
5338
5439
#![deny(warnings)]
5540

56-
mod event;
57-
mod file_header;
41+
pub mod file_header;
5842
#[cfg(any(not(target_arch = "wasm32"), target_os = "wasi"))]
5943
mod file_serialization_sink;
6044
#[cfg(not(target_arch = "wasm32"))]
6145
mod mmap_serialization_sink;
6246
mod profiler;
63-
mod profiling_data;
6447
mod raw_event;
6548
mod serialization;
6649
mod stringtable;
6750

6851
pub mod rustc;
69-
pub mod testing_common;
7052

71-
pub use crate::event::{Event, Timestamp};
7253
#[cfg(any(not(target_arch = "wasm32"), target_os = "wasi"))]
7354
pub use crate::file_serialization_sink::FileSerializationSink;
7455
#[cfg(not(target_arch = "wasm32"))]
7556
pub use crate::mmap_serialization_sink::MmapSerializationSink;
7657
pub use crate::profiler::{Profiler, ProfilerFiles, TimingGuard};
77-
pub use crate::profiling_data::{ProfilingData, ProfilingDataBuilder};
7858
pub use crate::raw_event::RawEvent;
7959
pub use crate::serialization::{Addr, ByteVecSink, SerializationSink};
8060
pub use crate::stringtable::{

mmview/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ license = "MIT OR Apache-2.0"
77

88
[dependencies]
99
measureme = { path = "../measureme" }
10+
tools_lib = { path = "../tools_lib" }
1011
structopt = "0.2"

mmview/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
use measureme::ProfilingData;
21
use std::error::Error;
32
use std::path::PathBuf;
3+
use tools_lib::ProfilingData;
44

55
use structopt::StructOpt;
66

stack_collapse/src/main.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,8 @@ use std::fs::File;
33
use std::io::{BufWriter, Write};
44
use std::path::PathBuf;
55

6-
use measureme::ProfilingData;
7-
86
use structopt::StructOpt;
9-
10-
use tools_lib::stack_collapse::collapse_stacks;
7+
use tools_lib::{collapse_stacks, ProfilingData};
118

129
#[derive(StructOpt, Debug)]
1310
struct Opt {

summarize/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ license = "MIT OR Apache-2.0"
77

88
[dependencies]
99
measureme = { path = "../measureme" }
10+
tools_lib = { path = "../tools_lib" }
1011
prettytable-rs = "0.8"
1112
rustc-hash = "1.0.1"
1213
serde = { version = "1.0", features = [ "derive" ] }

summarize/src/analysis.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
use crate::query_data::{QueryData, Results};
22
use measureme::rustc::*;
3-
use measureme::{Event, ProfilingData, Timestamp};
43
use rustc_hash::FxHashMap;
54
use std::borrow::Cow;
65
use std::time::SystemTime;
6+
use tools_lib::{Event, ProfilingData, Timestamp};
77

88
/// Collects accumulated summary data for the given ProfilingData.
99
///
@@ -220,7 +220,7 @@ pub fn perform_analysis(data: ProfilingData) -> Results {
220220
mod tests {
221221
use super::*;
222222
use std::time::Duration;
223-
use measureme::ProfilingDataBuilder;
223+
use tools_lib::ProfilingDataBuilder;
224224

225225
#[test]
226226
fn total_time_and_nesting() {

0 commit comments

Comments
 (0)