NVIDIA DeepStream SDK API Reference
8.0 Release
timer.hpp
Go to the documentation of this file.
1
/*
2
* SPDX-FileCopyrightText: Copyright (c) 2022-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3
* SPDX-License-Identifier: LicenseRef-NvidiaProprietary
4
*
5
* NVIDIA CORPORATION, its affiliates and licensors retain all intellectual
6
* property and proprietary rights in and to this material, related
7
* documentation and any modifications thereto. Any use, reproduction,
8
* disclosure or distribution of this material and related documentation
9
* without an express license agreement from NVIDIA CORPORATION or
10
* its affiliates is strictly prohibited.
11
*/
12
13
#ifndef __TIMER_HPP__
14
#define __TIMER_HPP__
15
16
#include "
check.hpp
"
17
18
namespace
nv
{
19
20
class
EventTimer
{
21
public
:
22
EventTimer
() {
23
checkRuntime
(cudaEventCreate(&begin_));
24
checkRuntime
(cudaEventCreate(&end_));
25
}
26
27
virtual
~EventTimer
() {
28
checkRuntime
(cudaEventDestroy(begin_));
29
checkRuntime
(cudaEventDestroy(end_));
30
}
31
32
void
start
(
cudaStream_t
stream) {
checkRuntime
(cudaEventRecord(begin_, stream)); }
33
34
float
stop
(
const
char
* prefix =
"timer"
) {
35
float
times = 0;
36
checkRuntime
(cudaEventRecord(end_, stream_));
37
checkRuntime
(cudaEventSynchronize(end_));
38
checkRuntime
(cudaEventElapsedTime(×, begin_, end_));
39
printf(
"[⏰ %s]: \t%.5f ms\n"
, prefix, times);
40
return
times;
41
}
42
43
private
:
44
cudaStream_t
stream_ =
nullptr
;
45
cudaEvent_t begin_ =
nullptr
, end_ =
nullptr
;
46
};
47
48
};
// namespace nv
49
50
#endif // __TIMER_HPP__
nv::EventTimer::stop
float stop(const char *prefix="timer")
Definition:
timer.hpp:34
nv::EventTimer::EventTimer
EventTimer()
Definition:
timer.hpp:22
nv::EventTimer::start
void start(cudaStream_t stream)
Definition:
timer.hpp:32
nv
Definition:
timer.hpp:18
cudaStream_t
struct CUstream_st * cudaStream_t
Forward declaration of cudaStream_t.
Definition:
nvbufsurftransform.h:35
checkRuntime
#define checkRuntime(call)
Definition:
check.hpp:43
check.hpp
nv::EventTimer::~EventTimer
virtual ~EventTimer()
Definition:
timer.hpp:27
nv::EventTimer
Definition:
timer.hpp:20
Privacy Policy
|
Manage My Privacy
|
Do Not Sell or Share My Data
|
Terms of Service
|
Accessibility
|
Corporate Policies
|
Product Security
|
Contact
© 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
NVIDIA Confidential | Subject to Change | For test and development only.
Tue Sep 9 2025 11:36:24 | PR-09318-R32