Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Alchemy Viewer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Package registry
Operate
Terraform modules
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Silent mode is enabled
All outbound communications are blocked.
Learn more
.
Show more breadcrumbs
Alchemy Viewer
Alchemy Viewer
Commits
b27bb47f
Commit
b27bb47f
authored
12 years ago
by
Monty Brandenberg
Browse files
Options
Downloads
Patches
Plain Diff
Implement metrics collection for Linux. Next: Mac OS X.
parent
6193ee6a
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
indra/llcorehttp/examples/http_texture_load.cpp
+148
-13
148 additions, 13 deletions
indra/llcorehttp/examples/http_texture_load.cpp
with
148 additions
and
13 deletions
indra/llcorehttp/examples/http_texture_load.cpp
+
148
−
13
View file @
b27bb47f
...
...
@@ -592,7 +592,7 @@ class Metrics::MetricsImpl
~
MetricsImpl
()
{}
void
MetricsImpl
::
init
(
Metrics
*
metrics
)
void
init
(
Metrics
*
metrics
)
{
HANDLE
self
(
GetCurrentProcess
());
// Does not have to be closed
FILETIME
ft_dummy
,
ft_system
,
ft_user
;
...
...
@@ -607,7 +607,7 @@ class Metrics::MetricsImpl
metrics
->
mStartWallTime
=
totalTime
();
}
void
MetricsImpl
::
sample
(
Metrics
*
metrics
)
void
sample
(
Metrics
*
metrics
)
{
PROCESS_MEMORY_COUNTERS_EX
counters
;
...
...
@@ -622,7 +622,7 @@ class Metrics::MetricsImpl
metrics
->
mMinVSZ
=
(
std
::
min
)(
metrics
->
mMinVSZ
,
U64
(
vsz
));
}
void
MetricsImpl
::
term
(
Metrics
*
metrics
)
void
term
(
Metrics
*
metrics
)
{
HANDLE
self
(
GetCurrentProcess
());
// Does not have to be closed
FILETIME
ft_dummy
,
ft_system
,
ft_user
;
...
...
@@ -652,13 +652,13 @@ class Metrics::MetricsImpl
~
MetricsImpl
()
{}
void
MetricsImpl
::
init
(
Metrics
*
)
void
init
(
Metrics
*
)
{}
void
MetricsImpl
::
sample
(
Metrics
*
)
void
sample
(
Metrics
*
)
{}
void
MetricsImpl
::
term
(
Metrics
*
)
void
term
(
Metrics
*
)
{}
};
...
...
@@ -668,24 +668,159 @@ class Metrics::MetricsImpl
{
public:
MetricsImpl
()
:
mProcFS
(
NULL
),
mUsecsPerTick
(
U64L
(
0
))
{}
~
MetricsImpl
()
{}
{
if
(
mProcFS
)
{
fclose
(
mProcFS
);
mProcFS
=
NULL
;
}
}
void
MetricsImpl
::
init
(
Metrics
*
)
{}
void
init
(
Metrics
*
metrics
)
{
if
(
!
mProcFS
)
{
mProcFS
=
fopen
(
"/proc/self/stat"
,
"r"
);
if
(
!
mProcFS
)
{
const
int
errnum
(
errno
);
LL_ERRS
(
"Main"
)
<<
"Error opening proc fs: "
<<
strerror
(
errnum
)
<<
LL_ENDL
;
}
}
long
ticks_per_sec
(
sysconf
(
_SC_CLK_TCK
));
mUsecsPerTick
=
U64L
(
1000000
)
/
ticks_per_sec
;
U64
usecs_per_sec
(
mUsecsPerTick
*
ticks_per_sec
);
if
(
900000
>
usecs_per_sec
||
1100000
<
usecs_per_sec
)
{
LL_ERRS
(
"Main"
)
<<
"Resolution problems using uSecs for ticks"
<<
LL_ENDL
;
}
U64
utime
,
stime
;
if
(
scanProcFS
(
&
utime
,
&
stime
,
NULL
))
{
metrics
->
mStartSTime
=
stime
;
metrics
->
mStartUTime
=
utime
;
}
metrics
->
mStartWallTime
=
totalTime
();
void
MetricsImpl
::
sample
(
M
etrics
*
)
{
}
sample
(
m
etrics
)
;
}
void
MetricsImpl
::
term
(
Metrics
*
)
{}
void
sample
(
Metrics
*
metrics
)
{
U64
vsz
;
if
(
scanProcFS
(
NULL
,
NULL
,
&
vsz
))
{
metrics
->
mMaxVSZ
=
(
std
::
max
)(
metrics
->
mMaxVSZ
,
vsz
);
metrics
->
mMinVSZ
=
(
std
::
min
)(
metrics
->
mMinVSZ
,
vsz
);
}
}
void
term
(
Metrics
*
metrics
)
{
U64
utime
,
stime
;
if
(
scanProcFS
(
&
utime
,
&
stime
,
NULL
))
{
metrics
->
mEndSTime
=
stime
;
metrics
->
mEndUTime
=
utime
;
}
metrics
->
mEndWallTime
=
totalTime
();
sample
(
metrics
);
if
(
mProcFS
)
{
fclose
(
mProcFS
);
mProcFS
=
NULL
;
}
}
protected
:
bool
scanProcFS
(
U64
*
utime
,
U64
*
stime
,
U64
*
vsz
)
{
if
(
mProcFS
)
{
int
i_dummy
;
unsigned
int
ui_dummy
;
unsigned
long
ul_dummy
,
user_ticks
,
sys_ticks
,
vsize
;
long
l_dummy
,
rss
;
unsigned
long
long
ull_dummy
;
char
c_dummy
;
char
buffer
[
256
];
static
const
char
*
format
(
"%d %*s %c %d %d %d %d %d %u %lu %lu %lu %lu %lu %lu %ld %ld %ld %ld %ld %ld %llu %lu %ld"
);
fseek
(
mProcFS
,
0L
,
SEEK_SET
);
size_t
len
=
fread
(
buffer
,
1
,
sizeof
(
buffer
)
-
1
,
mProcFS
);
if
(
!
len
)
{
return
false
;
}
buffer
[
len
]
=
'\0'
;
if
(
23
==
sscanf
(
buffer
,
format
,
&
i_dummy
,
// pid
// &s_dummy, // command name
&
c_dummy
,
// state
&
i_dummy
,
// ppid
&
i_dummy
,
// pgrp
&
i_dummy
,
// session
&
i_dummy
,
// terminal
&
i_dummy
,
// terminal group id
&
ui_dummy
,
// flags
&
ul_dummy
,
// minor faults
&
ul_dummy
,
// minor faults in children
&
ul_dummy
,
// major faults
&
ul_dummy
,
// major faults in children
&
user_ticks
,
&
sys_ticks
,
&
l_dummy
,
// cutime
&
l_dummy
,
// cstime
&
l_dummy
,
// process priority
&
l_dummy
,
// nice value
&
l_dummy
,
// thread count
&
l_dummy
,
// time to SIGALRM
&
ull_dummy
,
// start time
&
vsize
,
&
rss
))
{
// Looks like we understand the line
if
(
utime
)
{
*
utime
=
user_ticks
*
mUsecsPerTick
;
}
if
(
stime
)
{
*
stime
=
sys_ticks
*
mUsecsPerTick
;
}
if
(
vsz
)
{
*
vsz
=
vsize
;
}
return
true
;
}
}
return
false
;
}
protected
:
FILE
*
mProcFS
;
U64
mUsecsPerTick
;
};
#endif // defined(WIN32)
Metrics
::
Metrics
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment