Skip to content

Commit e5add84

Browse files
Rename FileSerializationSink to just SerializationSink, now that there is a single kind.
1 parent b74043c commit e5add84

File tree

10 files changed

+215
-221
lines changed

10 files changed

+215
-221
lines changed

analyzeme/benches/serialization_bench.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ extern crate test;
55
use analyzeme::testing_common;
66

77
#[bench]
8-
fn bench_file_serialization_sink(bencher: &mut test::Bencher) {
8+
fn bench_serialization_sink(bencher: &mut test::Bencher) {
99
bencher.iter(|| {
10-
testing_common::run_serialization_bench("file_serialization_sink_test", 500_000, 1);
10+
testing_common::run_serialization_bench("serialization_sink_test", 500_000, 1);
1111
});
1212
}
1313

1414
#[bench]
15-
fn bench_file_serialization_sink_8_threads(bencher: &mut test::Bencher) {
15+
fn bench_serialization_sink_8_threads(bencher: &mut test::Bencher) {
1616
bencher.iter(|| {
17-
testing_common::run_serialization_bench("file_serialization_sink_test", 50_000, 8);
17+
testing_common::run_serialization_bench("serialization_sink_test_8_threads", 50_000, 8);
1818
});
1919
}

analyzeme/src/profiling_data.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use measureme::file_header::{
66
read_file_header, write_file_header, CURRENT_FILE_FORMAT_VERSION, FILE_HEADER_SIZE,
77
FILE_MAGIC_EVENT_STREAM,
88
};
9-
use measureme::{EventId, FileSerializationSink, ProfilerFiles, RawEvent, StringTableBuilder};
9+
use measureme::{EventId, ProfilerFiles, RawEvent, SerializationSink, StringTableBuilder};
1010
use serde::{Deserialize, Deserializer};
1111
use std::error::Error;
1212
use std::fs;
@@ -199,17 +199,17 @@ impl<'a> DoubleEndedIterator for ProfilerEventIterator<'a> {
199199
/// implementation might not be efficient, which why it should only be used for
200200
/// writing tests and other things that are not performance sensitive.
201201
pub struct ProfilingDataBuilder {
202-
event_sink: FileSerializationSink,
203-
string_table_data_sink: Arc<FileSerializationSink>,
204-
string_table_index_sink: Arc<FileSerializationSink>,
202+
event_sink: SerializationSink,
203+
string_table_data_sink: Arc<SerializationSink>,
204+
string_table_index_sink: Arc<SerializationSink>,
205205
string_table: StringTableBuilder,
206206
}
207207

208208
impl ProfilingDataBuilder {
209209
pub fn new() -> ProfilingDataBuilder {
210-
let event_sink = FileSerializationSink::new_in_memory();
211-
let string_table_data_sink = Arc::new(FileSerializationSink::new_in_memory());
212-
let string_table_index_sink = Arc::new(FileSerializationSink::new_in_memory());
210+
let event_sink = SerializationSink::new_in_memory();
211+
let string_table_data_sink = Arc::new(SerializationSink::new_in_memory());
212+
let string_table_index_sink = Arc::new(SerializationSink::new_in_memory());
213213

214214
// The first thing in every file we generate must be the file header.
215215
write_file_header(&event_sink, FILE_MAGIC_EVENT_STREAM);

analyzeme/src/stringtable.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -243,13 +243,13 @@ impl StringTable {
243243
#[cfg(test)]
244244
mod tests {
245245
use super::*;
246-
use measureme::{FileSerializationSink, StringComponent, StringTableBuilder};
246+
use measureme::{SerializationSink, StringComponent, StringTableBuilder};
247247
use std::sync::Arc;
248248

249249
#[test]
250250
fn simple_strings() {
251-
let data_sink = Arc::new(FileSerializationSink::new_in_memory());
252-
let index_sink = Arc::new(FileSerializationSink::new_in_memory());
251+
let data_sink = Arc::new(SerializationSink::new_in_memory());
252+
let index_sink = Arc::new(SerializationSink::new_in_memory());
253253

254254
let expected_strings = &[
255255
"abc",
@@ -289,8 +289,8 @@ mod tests {
289289

290290
#[test]
291291
fn composite_string() {
292-
let data_sink = Arc::new(FileSerializationSink::new_in_memory());
293-
let index_sink = Arc::new(FileSerializationSink::new_in_memory());
292+
let data_sink = Arc::new(SerializationSink::new_in_memory());
293+
let index_sink = Arc::new(SerializationSink::new_in_memory());
294294

295295
let expected_strings = &[
296296
"abc", // 0

analyzeme/tests/serialization.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
use analyzeme::testing_common::run_end_to_end_serialization_test;
22

33
#[test]
4-
fn test_file_serialization_sink_1_thread() {
5-
run_end_to_end_serialization_test("file_serialization_sink_test_1_thread", 1);
4+
fn test_serialization_sink_1_thread() {
5+
run_end_to_end_serialization_test("serialization_sink_test_1_thread", 1);
66
}
77

88
#[test]
9-
fn test_file_serialization_sink_8_threads() {
10-
run_end_to_end_serialization_test("file_serialization_sink_test_8_threads", 8);
9+
fn test_serialization_sink_8_threads() {
10+
run_end_to_end_serialization_test("serialization_sink_test_8_threads", 8);
1111
}

measureme/src/file_header.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! All binary files generated by measureme have a simple file header that
22
//! consists of a 4 byte file magic string and a 4 byte little-endian version
33
//! number.
4-
use crate::FileSerializationSink;
4+
use crate::SerializationSink;
55
use std::convert::TryInto;
66
use std::error::Error;
77

@@ -14,7 +14,7 @@ pub const FILE_MAGIC_STRINGTABLE_INDEX: &[u8; 4] = b"MMSI";
1414
/// rely on this size to be `8`.
1515
pub const FILE_HEADER_SIZE: usize = 8;
1616

17-
pub fn write_file_header(s: &FileSerializationSink, file_magic: &[u8; 4]) {
17+
pub fn write_file_header(s: &SerializationSink, file_magic: &[u8; 4]) {
1818
// The implementation here relies on FILE_HEADER_SIZE to have the value 8.
1919
// Let's make sure this assumption cannot be violated without being noticed.
2020
assert_eq!(FILE_HEADER_SIZE, 8);
@@ -53,11 +53,11 @@ pub fn strip_file_header(data: &[u8]) -> &[u8] {
5353
#[cfg(test)]
5454
mod tests {
5555
use super::*;
56-
use crate::file_serialization_sink::FileSerializationSink;
56+
use crate::SerializationSink;
5757

5858
#[test]
5959
fn roundtrip() {
60-
let data_sink = FileSerializationSink::new_in_memory();
60+
let data_sink = SerializationSink::new_in_memory();
6161

6262
write_file_header(&data_sink, FILE_MAGIC_EVENT_STREAM);
6363

@@ -71,7 +71,7 @@ mod tests {
7171

7272
#[test]
7373
fn invalid_magic() {
74-
let data_sink = FileSerializationSink::new_in_memory();
74+
let data_sink = SerializationSink::new_in_memory();
7575
write_file_header(&data_sink, FILE_MAGIC_STRINGTABLE_DATA);
7676
let mut data = data_sink.into_bytes();
7777

@@ -82,7 +82,7 @@ mod tests {
8282

8383
#[test]
8484
fn other_version() {
85-
let data_sink = FileSerializationSink::new_in_memory();
85+
let data_sink = SerializationSink::new_in_memory();
8686

8787
write_file_header(&data_sink, FILE_MAGIC_STRINGTABLE_INDEX);
8888

measureme/src/file_serialization_sink.rs

Lines changed: 0 additions & 177 deletions
This file was deleted.

measureme/src/lib.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,6 @@
4040

4141
pub mod event_id;
4242
pub mod file_header;
43-
#[cfg(any(not(target_arch = "wasm32"), target_os = "wasi"))]
44-
mod file_serialization_sink;
45-
#[cfg(not(target_arch = "wasm32"))]
4643
mod profiler;
4744
mod raw_event;
4845
mod serialization;
@@ -51,10 +48,7 @@ pub mod stringtable;
5148
pub mod rustc;
5249

5350
pub use crate::event_id::{EventId, EventIdBuilder};
54-
#[cfg(any(not(target_arch = "wasm32"), target_os = "wasi"))]
55-
pub use crate::file_serialization_sink::FileSerializationSink;
56-
#[cfg(not(target_arch = "wasm32"))]
5751
pub use crate::profiler::{Profiler, ProfilerFiles, TimingGuard};
5852
pub use crate::raw_event::{RawEvent, MAX_INSTANT_TIMESTAMP, MAX_INTERVAL_TIMESTAMP};
59-
pub use crate::serialization::Addr;
53+
pub use crate::serialization::{Addr, SerializationSink};
6054
pub use crate::stringtable::{SerializableString, StringComponent, StringId, StringTableBuilder};

measureme/src/profiler.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::event_id::EventId;
22
use crate::file_header::{write_file_header, FILE_MAGIC_EVENT_STREAM};
3-
use crate::file_serialization_sink::FileSerializationSink;
43
use crate::raw_event::RawEvent;
4+
use crate::serialization::SerializationSink;
55
use crate::stringtable::{SerializableString, StringId, StringTableBuilder};
66
use std::error::Error;
77
use std::path::{Path, PathBuf};
@@ -25,22 +25,22 @@ impl ProfilerFiles {
2525
}
2626

2727
pub struct Profiler {
28-
event_sink: Arc<FileSerializationSink>,
28+
event_sink: Arc<SerializationSink>,
2929
string_table: StringTableBuilder,
3030
start_time: Instant,
3131
}
3232

3333
impl Profiler {
3434
pub fn new<P: AsRef<Path>>(path_stem: P) -> Result<Profiler, Box<dyn Error + Send + Sync>> {
3535
let paths = ProfilerFiles::new(path_stem.as_ref());
36-
let event_sink = Arc::new(FileSerializationSink::from_path(&paths.events_file)?);
36+
let event_sink = Arc::new(SerializationSink::from_path(&paths.events_file)?);
3737

3838
// The first thing in every file we generate must be the file header.
3939
write_file_header(&*event_sink, FILE_MAGIC_EVENT_STREAM);
4040

4141
let string_table = StringTableBuilder::new(
42-
Arc::new(FileSerializationSink::from_path(&paths.string_data_file)?),
43-
Arc::new(FileSerializationSink::from_path(&paths.string_index_file)?),
42+
Arc::new(SerializationSink::from_path(&paths.string_data_file)?),
43+
Arc::new(SerializationSink::from_path(&paths.string_index_file)?),
4444
);
4545

4646
let profiler = Profiler {

0 commit comments

Comments
 (0)