Argus Camera Sample
Argus Camera Sample
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
modules
PerfTracker.cpp
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
3
*
4
* Redistribution and use in source and binary forms, with or without
5
* modification, are permitted provided that the following conditions
6
* are met:
7
* * Redistributions of source code must retain the above copyright
8
* notice, this list of conditions and the following disclaimer.
9
* * Redistributions in binary form must reproduce the above copyright
10
* notice, this list of conditions and the following disclaimer in the
11
* documentation and/or other materials provided with the distribution.
12
* * Neither the name of NVIDIA CORPORATION nor the names of its
13
* contributors may be used to endorse or promote products derived
14
* from this software without specific prior written permission.
15
*
16
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
17
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
20
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
23
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
24
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
*/
28
29
#include <stdio.h>
30
#define __STDC_FORMAT_MACROS
31
#include <inttypes.h>
32
33
#include "
PerfTracker.h
"
34
#include "
Dispatcher.h
"
35
36
namespace
ArgusSamples
37
{
38
39
int
PerfTracker::s_count
= 0;
40
TimeValue
PerfTracker::ms_appStartTime
;
41
TimeValue
PerfTracker::ms_appInitializedTime
;
42
43
PerfTracker::PerfTracker
()
44
: m_id(s_count)
45
, m_numberframesReceived(0)
46
, m_lastFrameCount(0)
47
, m_totalFrameDrop(0)
48
{
49
s_count
++;
50
}
51
52
void
PerfTracker::onAppEvent
(
PerfEventType
type, uint64_t value)
53
{
54
switch
(type)
55
{
56
case
APP_START
:
57
ms_appStartTime
=
getCurrentTime
();
58
break
;
59
case
APP_INITIALIZED
:
60
ms_appInitializedTime
=
getCurrentTime
();
61
break
;
62
default
:
63
printf(
"unexpected type in perfTracker\n"
);
64
break
;
65
}
66
return
;
67
}
68
69
void
PerfTracker::onEvent
(
PerfEventType
type, uint64_t value)
70
{
71
if
(!
Dispatcher::getInstance
().m_kpi)
72
return
;
73
74
switch
(type)
75
{
76
case
TASK_START
:
77
m_taskStartTime
=
getCurrentTime
();
78
printf(
"PerfTracker: app initial %"
PRIu64
" ms\n"
,
79
(
ms_appInitializedTime
-
ms_appStartTime
).toMSec());
80
printf(
"PerfTracker %d: app intialized to task start %"
PRIu64
" ms\n"
,
m_id
,
81
(
m_taskStartTime
-
ms_appInitializedTime
).toMSec());
82
break
;
83
case
ISSUE_CAPTURE
:
84
m_issueCaptureTime
=
getCurrentTime
();
85
printf(
"PerfTracker %d: task start to issue capture %"
PRIu64
" ms\n"
,
m_id
,
86
(
m_issueCaptureTime
-
m_taskStartTime
).toMSec());
87
break
;
88
case
REQUEST_RECEIVED
:
89
m_requestReceivedTime
=
getCurrentTime
();
90
if
(
m_numberframesReceived
== 0)
91
{
92
m_firstRequestReceivedTime
=
m_requestReceivedTime
;
93
printf(
"PerfTracker %d: first request %"
PRIu64
" ms\n"
,
m_id
,
94
(
m_firstRequestReceivedTime
-
m_issueCaptureTime
).toMSec());
95
printf(
"PerfTracker %d: total launch time %"
PRIu64
" ms\n"
,
m_id
,
96
(
m_firstRequestReceivedTime
-
ms_appStartTime
).toMSec());
97
}
98
99
m_numberframesReceived
++;
100
if
((
m_numberframesReceived
% 30) == 2)
101
{
102
float
frameRate =
103
static_cast<
float
>
(
m_numberframesReceived
- 1) *
104
(
m_requestReceivedTime
-
m_firstRequestReceivedTime
).toCyclesPerSec();
105
printf(
"PerfTracker %d: frameRate %.2f frames per second\n"
,
m_id
, frameRate);
106
}
107
break
;
108
case
REQUEST_LATENCY
:
109
// can do some stats
110
printf(
"PerfTracker %d: latency %"
PRIu64
" ms\n"
,
m_id
, value);
111
break
;
112
case
FRAME_COUNT
:
113
{
114
uint64_t currentFrameCount = 0;
115
uint64_t currentFrameDrop = 0;
116
currentFrameCount = value;
117
// start frame drop count from 2nd frame
118
if
(
m_lastFrameCount
> 0)
119
{
120
currentFrameDrop = currentFrameCount -
m_lastFrameCount
- 1;
121
m_totalFrameDrop
+= currentFrameDrop;
122
}
123
printf(
"perfTracker %d: framedrop current request %"
PRIu64
", total %"
PRIu64
"\n"
,
124
m_id
, currentFrameDrop,
m_totalFrameDrop
);
125
m_lastFrameCount
= currentFrameCount;
126
break
;
127
}
128
case
CLOSE_REQUESTED
:
129
m_closeRequestedTime
=
getCurrentTime
();
130
break
;
131
case
FLUSH_DONE
:
132
m_flushDoneTime
=
getCurrentTime
();
133
printf(
"PerfTracker %d: flush takes %"
PRIu64
" ms\n"
,
m_id
,
134
(
m_flushDoneTime
-
m_closeRequestedTime
).toMSec());
135
break
;
136
case
CLOSE_DONE
:
137
m_closeDoneTime
=
getCurrentTime
();
138
printf(
"PerfTracker %d: device close takes %"
PRIu64
" ms\n"
,
m_id
,
139
(
m_closeDoneTime
-
m_flushDoneTime
).toMSec());
140
printf(
"PerfTracker %d: total close takes %"
PRIu64
" ms\n"
,
m_id
,
141
(
m_closeDoneTime
-
m_closeRequestedTime
).toMSec());
142
break
;
143
144
default
:
145
printf(
"unexpected type in perfTracker\n"
);
146
break
;
147
}
148
return
;
149
}
150
151
};
// namespace ArgusSamples
Generated on Thu Sep 22 2016 11:28:01 for Argus Camera Sample by
1.8.1