|
1 | 1 | // SPDX-FileCopyrightText: Copyright (c) 2024-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. |
2 | 2 | // SPDX-License-Identifier: Apache-2.0 |
3 | | -// |
4 | | -// Licensed under the Apache License, Version 2.0 (the "License"); |
5 | | -// you may not use this file except in compliance with the License. |
6 | | -// You may obtain a copy of the License at |
7 | | -// |
8 | | -// http://www.apache.org/licenses/LICENSE-2.0 |
9 | | -// |
10 | | -// Unless required by applicable law or agreed to in writing, software |
11 | | -// distributed under the License is distributed on an "AS IS" BASIS, |
12 | | -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
13 | | -// See the License for the specific language governing permissions and |
14 | | -// limitations under the License. |
15 | 3 |
|
16 | 4 | use serde::{Deserialize, Serialize}; |
17 | 5 | use std::io; |
@@ -386,6 +374,12 @@ where |
386 | 374 | } |
387 | 375 | } |
388 | 376 |
|
| 377 | +impl<T> Drop for Recorder<T> { |
| 378 | + fn drop(&mut self) { |
| 379 | + self.cancel.cancel(); |
| 380 | + } |
| 381 | +} |
| 382 | + |
389 | 383 | /// Helper function to create a rotated file path with an index suffix |
390 | 384 | fn create_rotated_path(base_path: &Path, index: usize) -> PathBuf { |
391 | 385 | let path_str = base_path.to_string_lossy(); |
@@ -471,11 +465,11 @@ mod tests { |
471 | 465 | // Check that both events were recorded |
472 | 466 | assert_eq!(recorder.event_count().await, 2); |
473 | 467 |
|
474 | | - // Check that the elapsed time is between 9 and 11 milliseconds |
| 468 | + // Check that the elapsed time is between 7 and 13 milliseconds |
475 | 469 | let elapsed_ms = recorder.elapsed_time().await.unwrap().as_millis(); |
476 | | - if !(9..=11).contains(&elapsed_ms) { |
| 470 | + if !(7..=13).contains(&elapsed_ms) { |
477 | 471 | println!("Actual elapsed time: {} ms", elapsed_ms); |
478 | | - assert!((9..=11).contains(&elapsed_ms)); |
| 472 | + assert!((7..=13).contains(&elapsed_ms)); |
479 | 473 | } |
480 | 474 |
|
481 | 475 | // Force shutdown to flush file |
|
0 commit comments