Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
U
utils
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
FSL
utils
Commits
410f27ab
Commit
410f27ab
authored
24 years ago
by
Mark Woolrich
Browse files
Options
Downloads
Patches
Plain Diff
*** empty log message ***
parent
08d3afa8
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
time_tracer.h
+20
-8
20 additions, 8 deletions
time_tracer.h
with
20 additions
and
8 deletions
time_tracer.h
+
20
−
8
View file @
410f27ab
...
@@ -22,11 +22,11 @@ namespace Utilities{
...
@@ -22,11 +22,11 @@ namespace Utilities{
public:
public:
TimingFunction
(
const
char
*
pstr
)
:
TimingFunction
(
const
char
*
pstr
)
:
str
(
pstr
),
str
(
pstr
),
time_taken
(
0
.0
),
time_taken
(
0
),
times_called
(
0
)
times_called
(
0
)
{}
{}
class
comparer
class
comparer
_name
{
{
public:
public:
bool
operator
()(
const
TimingFunction
*
t1
,
const
TimingFunction
*
t2
)
const
bool
operator
()(
const
TimingFunction
*
t1
,
const
TimingFunction
*
t2
)
const
...
@@ -35,10 +35,20 @@ namespace Utilities{
...
@@ -35,10 +35,20 @@ namespace Utilities{
}
}
};
};
class
comparer_time_taken
{
public:
bool
operator
()(
const
TimingFunction
*
t1
,
const
TimingFunction
*
t2
)
const
{
return
t1
->
time_taken
>
t2
->
time_taken
;
}
};
void
start
()
{
start_time
=
clock
();}
void
start
()
{
start_time
=
clock
();}
void
end
()
{
time_taken
+=
clock
()
-
start_time
;
times_called
++
;}
void
end
()
{
time_taken
+=
clock
()
-
start_time
;
times_called
++
;}
friend
comparer
;
friend
comparer_name
;
friend
comparer_time_taken
;
friend
ostream
&
operator
<<
(
ostream
&
ostr
,
const
TimingFunction
*
t
);
friend
ostream
&
operator
<<
(
ostream
&
ostr
,
const
TimingFunction
*
t
);
protected
:
protected
:
...
@@ -57,9 +67,9 @@ namespace Utilities{
...
@@ -57,9 +67,9 @@ namespace Utilities{
{
{
ostr
<<
"<tr><td>"
<<
t
->
str
;
ostr
<<
"<tr><td>"
<<
t
->
str
;
ostr
.
setf
(
0
,
ios
::
floatfield
);
ostr
.
setf
(
0
,
ios
::
floatfield
);
ostr
<<
"<td align=center>"
<<
t
->
time_taken
/
CLOCKS_PER_SEC
;
ostr
<<
"<td align=center>"
<<
float
(
t
->
time_taken
)
/
CLOCKS_PER_SEC
;
ostr
.
setf
(
ios
::
scientific
,
ios
::
floatfield
);
ostr
.
setf
(
ios
::
scientific
,
ios
::
floatfield
);
ostr
<<
"<td align=center>"
<<
t
->
times_called
<<
"<td align=center>"
<<
(
t
->
time_taken
/
t
->
times_called
)
/
CLOCKS_PER_SEC
;
ostr
<<
"<td align=center>"
<<
t
->
times_called
<<
"<td align=center>"
<<
(
t
->
time_taken
/
float
(
t
->
times_called
)
)
/
CLOCKS_PER_SEC
;
ostr
<<
"</tr>"
;
ostr
<<
"</tr>"
;
return
ostr
;
return
ostr
;
}
}
...
@@ -83,7 +93,7 @@ namespace Utilities{
...
@@ -83,7 +93,7 @@ namespace Utilities{
{
{
// see if already in list:
// see if already in list:
timingFunction
=
new
TimingFunction
(
str
);
timingFunction
=
new
TimingFunction
(
str
);
set
<
TimingFunction
*
,
TimingFunction
::
comparer
>::
iterator
it
=
timingFunctions
.
find
(
timingFunction
);
set
<
TimingFunction
*
,
TimingFunction
::
comparer
_name
>::
iterator
it
=
timingFunctions
.
find
(
timingFunction
);
if
(
it
==
timingFunctions
.
end
())
if
(
it
==
timingFunctions
.
end
())
{
{
timingFunctions
.
insert
(
timingFunction
);
timingFunctions
.
insert
(
timingFunction
);
...
@@ -112,11 +122,13 @@ namespace Utilities{
...
@@ -112,11 +122,13 @@ namespace Utilities{
static
void
dump_times
(
const
string
&
dir
)
static
void
dump_times
(
const
string
&
dir
)
{
{
multiset
<
TimingFunction
*
,
TimingFunction
::
comparer_time_taken
>
timingFunctionsByTimeTaken
(
timingFunctions
.
begin
(),
timingFunctions
.
end
());
ofstream
out
;
ofstream
out
;
out
.
open
((
dir
+
"/timings.html"
).
c_str
(),
ios
::
out
);
out
.
open
((
dir
+
"/timings.html"
).
c_str
(),
ios
::
out
);
out
<<
"<HTML><TITLE>Tracer Timings</TITLE><BODY><table border=3 cellspacing=5>"
<<
endl
;
out
<<
"<HTML><TITLE>Tracer Timings</TITLE><BODY><table border=3 cellspacing=5>"
<<
endl
;
out
<<
"<tr><td>Function<td align=center>Total Time(secs)<td align=center>Num of calls<td align=center>Time per call(secs)</tr>"
<<
endl
;
out
<<
"<tr><td>Function<td align=center>Total Time(secs)<td align=center>Num of calls<td align=center>Time per call(secs)</tr>"
<<
endl
;
copy
(
timingFunctions
.
begin
(),
timingFunctions
.
end
(),
ostream_iterator
<
TimingFunction
*>
(
out
,
"
\n
"
));
copy
(
timingFunctions
ByTimeTaken
.
begin
(),
timingFunctions
ByTimeTaken
.
end
(),
ostream_iterator
<
TimingFunction
*>
(
out
,
"
\n
"
));
out
<<
"</table></BODY></HTML>"
<<
endl
;
out
<<
"</table></BODY></HTML>"
<<
endl
;
out
.
close
();
out
.
close
();
}
}
...
@@ -128,7 +140,7 @@ namespace Utilities{
...
@@ -128,7 +140,7 @@ namespace Utilities{
static
bool
debug
;
static
bool
debug
;
static
bool
timingon
;
static
bool
timingon
;
static
unsigned
int
pad
;
static
unsigned
int
pad
;
static
set
<
TimingFunction
*
,
TimingFunction
::
comparer
>
timingFunctions
;
static
set
<
TimingFunction
*
,
TimingFunction
::
comparer
_name
>
timingFunctions
;
string
tmp
;
string
tmp
;
TimingFunction
*
timingFunction
;
TimingFunction
*
timingFunction
;
...
...
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