NVIDIA DeepStream SDK API Reference
9.1 Release
sources/includes/ds3d/common/helper/timer.hpp
Go to the documentation of this file.
1
/*
2
* SPDX-FileCopyrightText: Copyright (c) 2022-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3
* SPDX-License-Identifier: Apache-2.0
4
*
5
* Licensed under the Apache License, Version 2.0 (the "License");
6
* you may not use this file except in compliance with the License.
7
* You may obtain a copy of the License at
8
*
9
* http://www.apache.org/licenses/LICENSE-2.0
10
*
11
* Unless required by applicable law or agreed to in writing, software
12
* distributed under the License is distributed on an "AS IS" BASIS,
13
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
* See the License for the specific language governing permissions and
15
* limitations under the License.
16
*/
17
18
#ifndef __TIMER_HPP__
19
#define __TIMER_HPP__
20
21
#include "
check.hpp
"
22
23
namespace
nv
{
24
25
class
EventTimer
{
26
public
:
27
EventTimer
() {
28
checkRuntime
(cudaEventCreate(&begin_));
29
checkRuntime
(cudaEventCreate(&end_));
30
}
31
32
virtual
~EventTimer
() {
33
checkRuntime
(cudaEventDestroy(begin_));
34
checkRuntime
(cudaEventDestroy(end_));
35
}
36
37
void
start
(
cudaStream_t
stream) {
checkRuntime
(cudaEventRecord(begin_, stream)); }
38
39
float
stop
(
const
char
* prefix =
"timer"
) {
40
float
times = 0;
41
checkRuntime
(cudaEventRecord(end_, stream_));
42
checkRuntime
(cudaEventSynchronize(end_));
43
checkRuntime
(cudaEventElapsedTime(×, begin_, end_));
44
printf(
"[⏰ %s]: \t%.5f ms\n"
, prefix, times);
45
return
times;
46
}
47
48
private
:
49
cudaStream_t
stream_ =
nullptr
;
50
cudaEvent_t begin_ =
nullptr
, end_ =
nullptr
;
51
};
52
53
};
// namespace nv
54
55
#endif // __TIMER_HPP__
cudaStream_t
struct CUstream_st * cudaStream_t
Forward declaration of cudaStream_t.
Definition:
sources/includes/nvbufsurftransform.h:35
nv::EventTimer::stop
float stop(const char *prefix="timer")
Definition:
sources/includes/ds3d/common/helper/timer.hpp:39
check.hpp
nv::EventTimer::EventTimer
EventTimer()
Definition:
sources/includes/ds3d/common/helper/timer.hpp:27
nv::EventTimer::start
void start(cudaStream_t stream)
Definition:
sources/includes/ds3d/common/helper/timer.hpp:37
nv
Definition:
sources/includes/ds3d/common/helper/timer.hpp:23
nv::EventTimer::~EventTimer
virtual ~EventTimer()
Definition:
sources/includes/ds3d/common/helper/timer.hpp:32
checkRuntime
#define checkRuntime(call)
Definition:
sources/includes/ds3d/common/helper/check.hpp:48
nv::EventTimer
Definition:
sources/includes/ds3d/common/helper/timer.hpp:25
Privacy Policy
|
Manage My Privacy
|
Do Not Sell or Share My Data
|
Terms of Service
|
Accessibility
|
Corporate Policies
|
Product Security
|
Contact
© 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
NVIDIA Confidential | Subject to Change | For test and development only.
Thu Jul 9 2026 11:48:21 | PR-09318-R32