Rosetta
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Pages
src
basic
gpu
Timer.cc
Go to the documentation of this file.
1
// -*- mode:c++;tab-width:2;indent-tabs-mode:t;show-trailing-whitespace:t;rm-trailing-spaces:t -*-
2
// vi: set ts=2 noet:
3
//
4
// (c) Copyright Rosetta Commons Member Institutions.
5
// (c) This file is part of the Rosetta software suite and is made available under license.
6
// (c) The Rosetta software is developed by the contributing members of the Rosetta Commons.
7
// (c) For more information, see http://www.rosettacommons.org. Questions about this can be
8
// (c) addressed to University of Washington UW TechTransfer, email: license@u.washington.edu.
9
10
/// @file basic/gpu/Timer.cc
11
/// @brief High-resolution Timer (ns resolution)
12
/// @author Luki Goldschmidt (luki@mbi.ucla.edu)
13
14
#ifndef INCLUDED_basic_gpu_GPU_cc
15
#define INCLUDED_basic_gpu_GPU_cc
16
17
#include <
basic/gpu/Timer.hh
>
18
#include <iostream>
19
20
namespace
basic {
21
namespace
gpu
{
22
23
Timer::Timer
() {
24
tag_
= NULL;
25
t_
= NULL;
26
Reset
();
27
}
28
29
Timer::~Timer
() {
30
Report
(
tag_
);
31
}
32
33
Timer::Timer
(
const
char
*
tag
) {
34
t_
= NULL;
35
tag_
=
tag
;
36
Reset
();
37
}
38
39
Timer::Timer
(
basic::Tracer::TracerProxy
&
t
,
const
char
*
tag
) {
40
t_
= &
t
;
41
tag_
=
tag
;
42
Reset
();
43
}
44
45
#ifdef WIN32
46
void
Timer::Reset
() {
47
start
= clock();
48
}
49
50
double
Timer::GetTime
() {
51
end
= clock();
52
double
time = 1000 * (
end
-
start
) / CLOCKS_PER_SEC;
53
return
time;
54
}
55
56
#else
57
58
void
Timer::Reset
() {
59
gettimeofday(&
start
, NULL);
60
}
61
62
double
Timer::GetTime
() {
63
gettimeofday(&
end
, NULL);
64
double
time = ((
end
.tv_sec -
start
.tv_sec)*1000 + (
end
.tv_usec -
start
.tv_usec)/1000.);
65
return
time;
66
}
67
#endif
68
69
void
Timer::Report
(
const
char
*
tag
) {
70
71
double
time =
GetTime
();
72
if
(
t_
) {
73
if
( tag ) {
74
(*t_) <<
"Time ["
<< tag <<
"]: "
;
75
}
else
{
76
(*t_) <<
"Time: "
;
77
}
78
(*t_) << time <<
" ms"
<< std::endl;
79
}
else
{
80
if
(
tag_
) {
81
std::cout
<<
"Time ["
<< tag <<
"]: "
;
82
}
else
{
83
std::cout
<<
"Time: "
;
84
}
85
std::cout
<< time <<
" ms"
<< std::endl;
86
}
87
}
88
89
}
// gpu
90
}
// basic
91
92
#endif // INCLUDED_basic_gpu_GPU_cc
basic::gpu::Timer::Report
void Report(const char *tag=NULL)
Definition:
Timer.cc:69
basic::gpu::Timer::GetTime
double GetTime()
Definition:
Timer.cc:62
Timer.hh
High-resolution Timer (ns resolution, but on *nix only)
basic::gpu::Timer::~Timer
~Timer()
Definition:
Timer.cc:29
basic::gpu::Timer::end
struct timeval start end
Definition:
Timer.hh:32
basic::gpu::Timer::Reset
void Reset()
Definition:
Timer.cc:58
basic::gpu::Timer::tag_
const char * tag_
Definition:
Timer.hh:34
basic::options::OptionKeys::gpu::gpu
BooleanOptionKey const gpu
basic::Tracer::TracerProxy
Small inner class acting as a proxy to an object that hold it.
Definition:
Tracer.hh:228
basic::gpu::Timer::t_
basic::Tracer::TracerProxy * t_
Definition:
Timer.hh:35
utility::io::oc::cout
ocstream cout(std::cout)
Wrapper around std::cout.
Definition:
ocstream.hh:287
basic::gpu::Timer::Timer
Timer()
Definition:
Timer.cc:23
basic::options::OptionKeys::cutoutdomain::start
IntegerOptionKey const start
Definition:
Workshop5test.py:10
tag
rule< Scanner, tag_closure::context_t > tag
Definition:
Tag.cc:373
basic::options::OptionKeys::in::file::t
FileVectorOptionKey const t
Generated on Fri Mar 11 2016 12:01:46 for Rosetta by
1.8.7