本文整理汇总了C++中Stopwatch::Start方法的典型用法代码示例。如果您正苦于以下问题:C++ Stopwatch::Start方法的具体用法?C++ Stopwatch::Start怎么用?C++ Stopwatch::Start使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Stopwatch
的用法示例。
在下文中一共展示了Stopwatch::Start方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main()
{
Stopwatch stopwatch;
HANDLE hTimer = NULL;
// Create an unnamed waitable timer.
hTimer = CreateWaitableTimer(NULL, TRUE, NULL);
if (NULL == hTimer) {
printf("CreateWaitableTimer failed (%d)\n", GetLastError());
return 1;
}
// With Sleep
stopwatch.Start();
DoWait(hTimer, 1000);
printf("Wait 1000ms, Elapsed time : %d\n", stopwatch.ElapsedTime());
// With Sleep
stopwatch.Start();
DoWait(hTimer, 1234);
Sleep(100);
printf("Wait 1234ms with Sleep(100), Elapsed time : %d\n", stopwatch.ElapsedTime());
return 0;
}
示例2: glClear
//------------------------------------------------------------------------------
static void
display() {
Stopwatch s;
s.Start();
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glViewport(0, 0, g_width, g_height);
g_hud.FillBackground();
double aspect = g_width/(double)g_height;
identity(g_transformData.ModelViewMatrix);
translate(g_transformData.ModelViewMatrix, -g_pan[0], -g_pan[1], -g_dolly);
rotate(g_transformData.ModelViewMatrix, g_rotate[1], 1, 0, 0);
rotate(g_transformData.ModelViewMatrix, g_rotate[0], 0, 1, 0);
rotate(g_transformData.ModelViewMatrix, -90, 1, 0, 0);
translate(g_transformData.ModelViewMatrix,
-g_center[0], -g_center[1], -g_center[2]);
perspective(g_transformData.ProjectionMatrix,
45.0f, (float)aspect, 0.01f, 500.0f);
multMatrix(g_transformData.ModelViewProjectionMatrix,
g_transformData.ModelViewMatrix,
g_transformData.ProjectionMatrix);
glEnable(GL_DEPTH_TEST);
drawStencils();
// draw the control mesh
g_controlMeshDisplay.Draw(g_stencilOutput->BindSrcBuffer(), 3*sizeof(float),
g_transformData.ModelViewProjectionMatrix);
s.Stop();
float drawCpuTime = float(s.GetElapsed() * 1000.0f);
s.Start();
glFinish();
s.Stop();
float drawGpuTime = float(s.GetElapsed() * 1000.0f);
if (g_hud.IsVisible()) {
g_fpsTimer.Stop();
double fps = 1.0/g_fpsTimer.GetElapsed();
g_fpsTimer.Start();
g_hud.DrawString(10, -100, "# stencils : %d", g_nsamplesDrawn);
g_hud.DrawString(10, -80, "EvalStencils : %.3f ms", g_evalTime);
g_hud.DrawString(10, -60, "GPU Draw : %.3f ms", drawGpuTime);
g_hud.DrawString(10, -40, "CPU Draw : %.3f ms", drawCpuTime);
g_hud.DrawString(10, -20, "FPS : %3.1f", fps);
g_hud.Flush();
}
glFinish();
//checkGLErrors("display leave");
}
示例3: sin
//------------------------------------------------------------------------------
void
updateGeom() {
int nverts = (int)g_orgPositions.size() / 3;
std::vector<float> vertex;
vertex.reserve(nverts*6);
const float *p = &g_orgPositions[0];
const float *n = &g_normals[0];
float r = sin(g_frame*0.001f) * g_moveScale;
for (int i = 0; i < nverts; ++i) {
float move = 0.05f*cosf(p[0]*20+g_frame*0.01f);
float ct = cos(p[2] * r);
float st = sin(p[2] * r);
g_positions[i*3+0] = p[0]*ct + p[1]*st;
g_positions[i*3+1] = -p[0]*st + p[1]*ct;
g_positions[i*3+2] = p[2];
p += 3;
}
p = &g_positions[0];
for (int i = 0; i < nverts; ++i) {
vertex.push_back(p[0]);
vertex.push_back(p[1]);
vertex.push_back(p[2]);
vertex.push_back(n[0]);
vertex.push_back(n[1]);
vertex.push_back(n[2]);
p += 3;
n += 3;
}
if (!g_vertexBuffer)
g_vertexBuffer = g_osdmesh->InitializeVertexBuffer(6);
g_vertexBuffer->UpdateData(&vertex[0], nverts);
Stopwatch s;
s.Start();
g_osdmesh->Subdivide(g_vertexBuffer, NULL);
s.Stop();
g_cpuTime = float(s.GetElapsed() * 1000.0f);
s.Start();
g_osdmesh->Synchronize();
s.Stop();
g_gpuTime = float(s.GetElapsed() * 1000.0f);
glBindBuffer(GL_ARRAY_BUFFER, g_vertexBuffer->GetGpuBuffer());
glBindBuffer(GL_ARRAY_BUFFER, 0);
}
示例4: main
int main(int argc, char* argv[])
{
LinearEquationSystemFactory factory;
LinearEquationSystemSolver solver;
for (; n <= nLimit; n *= multiplier)
{
float minTime = FLT_MAX;
for (int attempt = 0; attempt < repeatsNumber; ++attempt)
{
LinearEquationSystem* system = factory.Create(n);
NUMBER* solution = new NUMBER[n];
stopwatch.Start();
solver.Solve(system, solution);
stopwatch.Stop();
float elapsedSeconds = stopwatch.GetElapsedSeconds();
if (elapsedSeconds < minTime)
{
minTime = elapsedSeconds;
}
bool result = checker.IsCorrectSolution(system, solution);
printf("Correct: %s \n", result ? "yes" : "no");
delete system;
delete []solution;
}
printf("N = %d, Elapsed seconds: %f\n", n, minTime);
}
}
示例5: do_parallel_map
static void do_parallel_map(Stopwatch& sw) {
// Create a bunch of subcontexts from here and put them in a map
auto all = create();
::ContextMap<size_t> mp;
for (size_t i = N; i < all.size(); i++)
mp.Add(i, all[i]);
// Now the threads that will make progress hard:
auto proceed = std::make_shared<bool>(true);
for (size_t i = N; i--;)
std::thread([proceed, mp] {
while (*proceed)
for (const auto& cur : mp)
;
}).detach();
auto cleanup = MakeAtExit([&] { *proceed = false; });
std::this_thread::sleep_for(std::chrono::milliseconds(100));
// Enumerate the map while iteration is underway
sw.Start();
for (auto& cur : mp)
;
sw.Stop(n);
}
示例6: accum
__attribute__((noinline)) void benchNavigatorNoReloc(VNavigator const *se, SOA3D<Precision> const &points,
SOA3D<Precision> const &dirs, NavStatePool const &inpool,
NavStatePool &outpool)
{
Precision *steps = new Precision[points.size()];
Precision *safeties;
if (WithSafety) safeties = new Precision[points.size()];
Stopwatch timer;
size_t hittargetchecksum = 0L;
timer.Start();
for (decltype(points.size()) i = 0; i < points.size(); ++i) {
if (WithSafety) {
steps[i] = se->ComputeStepAndSafety(points[i], dirs[i], vecgeom::kInfLength, *inpool[i], true, safeties[i]);
} else {
steps[i] = se->ComputeStep(points[i], dirs[i], vecgeom::kInfLength, *inpool[i], *outpool[i]);
}
}
timer.Stop();
std::cerr << timer.Elapsed() << "\n";
double accum(0.), saccum(0.);
for (decltype(points.size()) i = 0; i < points.size(); ++i) {
accum += steps[i];
if (WithSafety) {
saccum += safeties[i];
}
if (outpool[i]->Top()) hittargetchecksum += (size_t)outpool[i]->Top()->id();
}
delete[] steps;
std::cerr << "accum " << se->GetName() << " " << accum << " target checksum " << hittargetchecksum << "\n";
if (WithSafety) {
std::cerr << "saccum " << se->GetName() << " " << saccum << "\n";
}
}
示例7: sin
static void
updateGeom() {
int nverts = (int)g_orgPositions.size() / 3;
const float *p = &g_orgPositions[0];
float r = sin(g_frame*0.001f) * g_moveScale;
g_positions.resize(nverts*3);
for (int i = 0; i < nverts; ++i) {
//float move = 0.05f*cosf(p[0]*20+g_frame*0.01f);
float ct = cos(p[2] * r);
float st = sin(p[2] * r);
g_positions[i*3+0] = p[0]*ct + p[1]*st;
g_positions[i*3+1] = -p[0]*st + p[1]*ct;
g_positions[i*3+2] = p[2];
p+=3;
}
Stopwatch s;
s.Start();
// update control points
g_stencilOutput->UpdateData(&g_positions[0], 0, nverts);
// Update random points by applying point & tangent stencils
g_stencilOutput->EvalStencils();
s.Stop();
g_evalTime = float(s.GetElapsed() * 1000.0f);
}
示例8: main
int main ( ) {
using namespace Furrovine;
using namespace Furrovine::Audio;
using namespace Furrovine::Pipeline;
//using namespace Furrovine::Graphics;
const static uint32 samplerate = 48000;
const static uint32 bitspersample = 16;
const static uint32 channelcount = 2;
PCMAudioData data = WavAudioLoader( )( "16bit.wav" );
AudioDevice baseaudiodevice( bitspersample, channelcount, samplerate );
RealtimeAudioDevice audiodevice( baseaudiodevice, milliseconds( 10 ) );
audiodevice.AddDSP( PerChannelDelay( audiodevice.PCMDescription( ), { seconds( 0.513 ), seconds( 0.490 ) }, real( 0.25 ) ) );
AudioBuffer buffer( data.Buffer(), 0, 0, 0, 0, 1 );
audiodevice.SubmitBuffer( buffer );
Stopwatch stopwatch;
stopwatch.Start( );
while ( true ) {
double seconds = stopwatch.ElapsedSeconds( );
if ( seconds < 1 )
continue;
//audiodevice.SubmitBuffer( buffer );
stopwatch.Restart( );
}
}
示例9: benchNoCachingNoVector
int benchNoCachingNoVector(Vector3D<Precision> const &point, Vector3D<Precision> const &dir,
std::vector<Vector3D<Precision>> const &corners
#ifdef SORTHITBOXES
,
Container_t &hitlist
#endif
)
{
#ifdef INNERTIMER
Stopwatch timer;
timer.Start();
#endif
int vecsize = corners.size() / 2;
int hitcount = 0;
for (auto box = 0; box < vecsize; ++box) {
double distance = BoxImplementation<translation::kIdentity, rotation::kIdentity>::Intersect(
&corners[2 * box], point, dir, 0, vecgeom::kInfLength);
if (distance < vecgeom::kInfLength) {
hitcount++;
#ifdef SORTHITBOXES
hitlist.push_back(BoxIdDistancePair_t(box, distance));
#endif
}
}
#ifdef INNERTIMER
timer.Stop();
std::cerr << "# ORDINARY hitting " << hitcount << "\n";
std::cerr << "# ORDINARY timer " << timer.Elapsed() << "\n";
#endif
return hitcount;
}
示例10: DoAll
//-------------------------------------------------------------------------------------------------
void Benchmark::DoAll(std::vector<string> vExpr, long num)
{
printf("\n\n\n");
PreprocessExpr(vExpr);
char outstr[400], file[400];
time_t t = time(NULL);
#ifdef _DEBUG
sprintf(outstr, "Bench_%s_%%Y%%m%%d_%%H%%M%%S_dbg.txt", GetShortName().c_str());
#else
sprintf(outstr, "Bench_%s_%%Y%%m%%d_%%H%%M%%S_rel.txt", GetShortName().c_str());
#endif
strftime(file, sizeof(file), outstr, localtime(&t));
FILE *pRes = fopen(file, "w");
assert(pRes);
fprintf(pRes, "# Benchmark results\n");
fprintf(pRes, "# Parser: %s\n", GetName().c_str());
fprintf(pRes, "# Evals per expr: %ld\n", num);
fprintf(pRes, "#\"ms per eval [ms]\", \"evals per sec\", \"Result\", \"expr_len\", \"Expression\"\n");
std::string sExpr;
Stopwatch timer;
timer.Start();
for (std::size_t i = 0; i < vExpr.size(); ++i)
{
try
{
DoBenchmark(vExpr[i], num);
fprintf(pRes, "%4.6lf, %4.6lf, %4.6lf, %d, %s, %s\n", m_fTime1, 1000.0/m_fTime1, m_fResult, (int)vExpr[i].length(), vExpr[i].c_str(), m_sInfo.c_str());
printf( "%4.6lf, %4.6lf, %4.6lf, %d, %s, %s\n", m_fTime1, 1000.0/m_fTime1, m_fResult, (int)vExpr[i].length(), vExpr[i].c_str(), m_sInfo.c_str());
}
catch(...)
{
fprintf(pRes, "fail: %s\n", vExpr[i].c_str());
printf( "fail: %s\n", vExpr[i].c_str());
}
fflush(pRes);
}
double dt = timer.Stop() / ((double)vExpr.size() * num);
fprintf(pRes, "# avg. time per expr.: %lf ms; avg. eval per sec: %lf; total bytecode size: %d",
dt,
1000.0 / dt,
m_nTotalBytecodeSize);
printf("\n#\n# avg. time per expr.: %lf ms; avg. eval per sec: %lf; total bytecode size: %d",
dt,
1000.0 / dt,
m_nTotalBytecodeSize);
fclose(pRes);
}
示例11: collider
void playback_exact_CSpace_R3()
{
C2A_Model* P = NULL;
C2A_Model* Q = NULL;
readObjFile(P, "../data/models/CupSpoon/Cup.obj");
readObjFile(Q, "../data/models/CupSpoon/Spoon.obj");
P->ComputeRadius();
Q->ComputeRadius();
Collider3D collider(P, Q);
C2A_Model* CSpace;
readObjFile(CSpace, "../data/cupspoon.obj");
std::vector<ContactSpaceSampleData> contactspace_samples;
std::ifstream in("space_test_3d.txt");
asciiReader(in, contactspace_samples);
std::ofstream timing_file("timing_exact_R3.txt");
std::ofstream PD_file("PD_exact_R3.txt");
for(std::size_t i = 0; i < contactspace_samples.size(); ++i)
{
std::cout << i << std::endl;
DataVector q_col(6);
DataVector q(3);
for(std::size_t j = 0; j < 3; ++j)
q[j] = contactspace_samples[i].v[j];
for(std::size_t j = 0; j < 6; ++j)
q_col[j] = contactspace_samples[i].v[j];
boost::timer t;
//aTimer.Reset();
aTimer.Start();
std::pair<DataVector, double> pd_result;
if(!collider.isCollide(q_col))
{
pd_result.second = 0;
}
else
{
pd_result = Minkowski_Cspace_3D::Exact_PD_R3(q, CSpace);
}
aTimer.Stop();
PD_file << pd_result.second << " ";
//timing_file << t.elapsed() << " ";
timing_file << aTimer.GetTime() * 1000 << " ";
timing_file.flush();
PD_file.flush();
}
}
示例12:
double
OsdMesh::Synchronize() {
Stopwatch s;
s.Start();
{
_dispatcher->Synchronize();
}
s.Stop();
return s.GetElapsed();
}
示例13: loops
void Benchmark::Integer8_Test()
{
double Score ( 0 ),
Cur_Time( 0 );
uint32_t loops ( 0 );
Stopwatch watch;
watch.Start();
for( ; Cur_Time < Time_Per_Test; ++loops, watch.Look( Cur_Time ), Status_Done( static_cast< uint32_t >( Status_Mul*Cur_Time )) )
Score += Intern_Integer8_Test();
m_Integer8_Score = static_cast< uint32_t >(Score/loops);
}
示例14: tmp
void Benchmark::Integer16_Test()
{
double tmp(0);
double Cur_Time(0);
uint32_t loops=0;
Stopwatch watch;
watch.Start();
for( ; Cur_Time < Time_Per_Test; ++loops, watch.Look( Cur_Time ), Status_Done( static_cast< uint32_t >( Status_Mul*Cur_Time )) )
tmp += Intern_Integer16_Test();
m_Integer16_Score = static_cast< uint32_t >(tmp/loops);
}
示例15: Test1
void Test1()
{
DIVIDING_LINE_1('-');
constexpr int Count = 2001001;
#if HAS_BOOST
boost::recursive_mutex osMutex;
ostream_t os(std::cout, osMutex);
#else
ostream_t &os = std::cout;
#endif
Stopwatch sw;
sw.Start();
ProducerConsumerContext context(os, Count, Count / 10, ENABLE_LOGGING);
Producer p1(context, 0, Count / 2, 200);
Producer p2(context, Count / 2, Count - Count / 2, 200);
Consumer c1(context, Count / 3, 200);
Consumer c2(context, Count / 3, 200);
Consumer c3(context, Count - Count / 3 - Count / 3, 200);
std::vector<std::thread> threads;
threads.push_back(p1.Create());
threads.push_back(p2.Create());
threads.push_back(c1.Create());
threads.push_back(c2.Create());
threads.push_back(c3.Create());
for (auto &t : threads)
t.join();
sw.Stop();
std::cout << "Ellapsed time: " << sw.GetElapsedMilliseconds() << "ms" << std::endl;
std::cout << "Checking if test is passed...\n";
sw.Restart();
bool ok = context.IsTestPassed();
sw.Stop();
std::cout << "It takes " << sw.GetElapsedMilliseconds() << "ms to figure out if test is passed." << std::endl;
std::cout << "Is test passed? " << std::boolalpha << ok << std::endl;
}