void StressTest::OnTimer() { KillTimer(win->hwndFrame, DIR_STRESS_TIMER_ID); if (!win->dm || !win->dm->engine) return; // chm documents aren't rendered and we block until we show them // so we can assume previous page has been shown and go to next page if (win->dm->AsChmEngine()) { if (!GoToNextPage()) return; goto Next; } // For non-image files, we detect if a page was rendered by checking the cache // (but we don't wait more than 3 seconds). // Image files are always fully rendered in WM_PAINT, so we know the page // has already been rendered. bool didRender = renderCache->Exists(win->dm, currPage, win->dm->Rotation()); if (!didRender && DoCachePageRendering(win, currPage)) { double timeInMs = currPageRenderTime.GetTimeInMs(); if (timeInMs > 3.0 * 1000) { if (!GoToNextPage()) return; } } else { if (!GoToNextPage()) return; } Next: MakeRandomSelection(win->dm, currPage); TickTimer(); }
void RunExhaustiveDocsimSearch() { const char *topicoutput = Config("RESULTS-PATH"); FILE *fo; if (topicoutput) { fo = fopen(topicoutput, "wb"); if (!fo) { fprintf(stderr, "The results file \"%s\" could not be opened for writing.\n", topicoutput); exit(1); } } else { fo = stdout; } unsigned char *sigFile; SignatureHeader sigCfg = readSigFile(Config("SIGNATURE-PATH"), &sigFile); int threadCount = 1; int searchDocFirst = 0; int searchDocLast = (sigCfg.num_signatures - 1); if (Config("THREADS")) { threadCount = atoi(Config("THREADS")); } if (Config("SEARCH-DOC-FIRST")) searchDocFirst = atoi(Config("SEARCH-DOC-FIRST")); if (Config("SEARCH-DOC-LAST")) searchDocLast = atoi(Config("SEARCH-DOC-LAST")); int totalDocs = searchDocLast - searchDocFirst + 1; void **threads = malloc(sizeof(void *) * threadCount); for (int i = 0; i < threadCount; i++) { WorkerThroughput *threadData = malloc(sizeof(WorkerThroughput)); threadData->sig_cfg = &sigCfg; threadData->sigFile = sigFile; threadData->doc_begin = totalDocs * i / threadCount + searchDocFirst; threadData->doc_end = totalDocs * (i+1) / threadCount + searchDocFirst; threads[i] = threadData; } Timer T = StartTimer(); DivideWork(threads, Throughput_Job, threadCount); for (int i = 0; i < threadCount; i++) { WorkerThroughput *thread_data = threads[i]; int doc_count = thread_data->doc_end - thread_data->doc_begin; for (int j = 0; j < doc_count; j++) { int topicId = thread_data->doc_begin + j; const char *docName = (const char *)(sigFile + (size_t)sigCfg.sig_record_size * topicId); writeResults(fo, topicId, docName, &thread_data->output[j]); } } fprintf(stderr, "search time %.2fms\n", TickTimer(&T)); for (int i = 0; i < threadCount; i++) { free(threads[i]); } free(threads); }
void StressTest::OnTimer(int timerIdGot) { CrashIf(timerId != timerIdGot); KillTimer(win->hwndFrame, timerId); if (!win->IsDocLoaded()) { if (!GoToNextFile()) { Finished(true); return; } TickTimer(); return; } // chm documents aren't rendered and we block until we show them // so we can assume previous page has been shown and go to next page if (!win->AsFixed()) { if (!GoToNextPage()) return; goto Next; } // For non-image files, we detect if a page was rendered by checking the cache // (but we don't wait more than 3 seconds). // Image files are always fully rendered in WM_PAINT, so we know the page // has already been rendered. DisplayModel *dm = win->AsFixed(); bool didRender = gRenderCache.Exists(dm, currPage, dm->GetRotation()); if (!didRender && dm->ShouldCacheRendering(currPage)) { double timeInMs = currPageRenderTime.GetTimeInMs(); if (timeInMs > 3.0 * 1000) { if (!GoToNextPage()) return; } } else if (!GoToNextPage()) { return; } MakeRandomSelection(win, currPage); Next: TickTimer(); }
void StressTest::Start(TestFileProvider* fileProvider, int cycles) { GetSystemTime(&stressStartTime); this->fileProvider = fileProvider; this->cycles = cycles; if (pageRanges.size() == 0) pageRanges.Append(PageRange()); if (fileRanges.size() == 0) fileRanges.Append(PageRange()); TickTimer(); }
bool Framework::FrameworkUpdate() { if(!running) return true; glfwSwapBuffers(window); glfwPollEvents(); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); TickTimer(); return glfwWindowShouldClose(window); }
void StressTest::Start(const TCHAR *path, const TCHAR *filter, const TCHAR *ranges, int cycles) { srand((unsigned int)time(NULL)); GetSystemTime(&stressStartTime); // forbid entering sleep mode during tests SetThreadExecutionState(ES_CONTINUOUS | ES_SYSTEM_REQUIRED | ES_DISPLAY_REQUIRED); basePath.Set(str::Dup(path)); fileFilter.Set(filter && !str::Eq(filter, _T("*")) ? str::Dup(filter) : NULL); if (file::Exists(basePath)) { filesToOpen.Append(str::Dup(basePath)); ParsePageRanges(ranges, pageRanges); } else if (dir::Exists(basePath)) { OpenDir(basePath); ParsePageRanges(ranges, fileRanges); } else { // Note: dev only, don't translate ScopedMem<TCHAR> s(str::Format(_T("Path '%s' doesn't exist"), path)); ShowNotification(win, s, false /* autoDismiss */, true, NG_STRESS_TEST_SUMMARY); Finished(false); return; } this->cycles = cycles; if (pageRanges.Count() == 0) pageRanges.Append(PageRange()); if (fileRanges.Count() == 0) fileRanges.Append(PageRange()); if (GoToNextFile()) TickTimer(); else Finished(true); }
void LegacyTimer::EndTimer() { QueryPerformanceCounter(&endTime); TickTimer(); }