Skip to content

Commit afb45b5

Browse files
authored
fix(source): rename --microseconds flag to --milliseconds (#75)
1 parent 66ce127 commit afb45b5

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

src/main.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -364,8 +364,8 @@ enum SourceCommand {
364364
#[arg(long)]
365365
end: String,
366366
/// Also test milliseconds (1000x more keys)
367-
#[arg(long)]
368-
microseconds: bool,
367+
#[arg(long, alias = "microseconds")]
368+
milliseconds: bool,
369369
},
370370

371371
/// Read from stdin (streaming)
@@ -1149,11 +1149,11 @@ fn create_source(cmd: SourceCommand) -> Result<Box<dyn Source>> {
11491149
SourceCommand::Timestamps {
11501150
start,
11511151
end,
1152-
microseconds,
1152+
milliseconds,
11531153
} => Ok(Box::new(TimestampSource::from_dates(
11541154
&start,
11551155
&end,
1156-
microseconds,
1156+
milliseconds,
11571157
)?)),
11581158
SourceCommand::Stdin => Ok(Box::new(StdinSource::new())),
11591159
SourceCommand::Files { file, dir } => match (file, dir) {

src/source/timestamps.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ use crate::transform::{Input, Transform};
1515
pub struct TimestampSource {
1616
start: u64,
1717
end: u64,
18-
microseconds: bool,
18+
milliseconds: bool,
1919
}
2020

2121
impl TimestampSource {
22-
pub fn from_dates(start_date: &str, end_date: &str, microseconds: bool) -> Result<Self> {
22+
pub fn from_dates(start_date: &str, end_date: &str, milliseconds: bool) -> Result<Self> {
2323
let start = NaiveDate::parse_from_str(start_date, "%Y-%m-%d")?
2424
.and_hms_opt(0, 0, 0)
2525
.unwrap()
@@ -50,7 +50,7 @@ impl TimestampSource {
5050
Ok(Self {
5151
start,
5252
end,
53-
microseconds,
53+
milliseconds,
5454
})
5555
}
5656
}
@@ -71,9 +71,9 @@ impl Source for TimestampSource {
7171
);
7272
}
7373

74-
if self.microseconds && self.end > (u64::MAX - 999) / 1000 {
74+
if self.milliseconds && self.end > (u64::MAX - 999) / 1000 {
7575
anyhow::bail!(
76-
"Timestamp value overflow in microseconds mode for end timestamp {}",
76+
"Timestamp value overflow in milliseconds mode for end timestamp {}",
7777
self.end
7878
);
7979
}
@@ -89,10 +89,10 @@ impl Source for TimestampSource {
8989
self.end
9090
)
9191
})?;
92-
let total = if self.microseconds {
92+
let total = if self.milliseconds {
9393
count.checked_mul(1001).ok_or_else(|| {
9494
anyhow::anyhow!(
95-
"Timestamp workload overflow in microseconds mode for {} inputs",
95+
"Timestamp workload overflow in milliseconds mode for {} inputs",
9696
count
9797
)
9898
})?
@@ -110,8 +110,8 @@ impl Source for TimestampSource {
110110
// Process base timestamp
111111
process_timestamp(ts, transforms, &deriver, matcher, output, &stats, &matches);
112112

113-
// Process microseconds if enabled
114-
if self.microseconds {
113+
// Process milliseconds if enabled
114+
if self.milliseconds {
115115
for ms in 0u64..1000 {
116116
let ts_ms = ts * 1000 + ms;
117117
process_timestamp(
@@ -153,11 +153,11 @@ mod tests {
153153
}
154154

155155
#[test]
156-
fn process_counts_microseconds_mode_correctly() {
156+
fn process_counts_milliseconds_mode_correctly() {
157157
let source = TimestampSource {
158158
start: 1,
159159
end: 1,
160-
microseconds: true,
160+
milliseconds: true,
161161
};
162162
let deriver = KeyDeriver::new();
163163
let output = ConsoleOutput::new();
@@ -175,7 +175,7 @@ mod tests {
175175
let source = TimestampSource {
176176
start: 10,
177177
end: 1,
178-
microseconds: false,
178+
milliseconds: false,
179179
};
180180
let deriver = KeyDeriver::new();
181181
let output = ConsoleOutput::new();
@@ -190,7 +190,7 @@ mod tests {
190190
let source = TimestampSource {
191191
start: 0,
192192
end: u64::MAX,
193-
microseconds: false,
193+
milliseconds: false,
194194
};
195195
let deriver = KeyDeriver::new();
196196
let output = ConsoleOutput::new();

0 commit comments

Comments
 (0)