本文整理汇总了C++中Stopwatch::stop方法的典型用法代码示例。如果您正苦于以下问题:C++ Stopwatch::stop方法的具体用法?C++ Stopwatch::stop怎么用?C++ Stopwatch::stop使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Stopwatch
的用法示例。
在下文中一共展示了Stopwatch::stop方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testSizes
//------------------------------------------------------------------------------
// Perform testcases for a 1 column table, a 2 column table, etc, up to
// a table having "maxCols" columns.
//------------------------------------------------------------------------------
void testSizes()
{
// Prompt for schema.
cout << "Enter Schema or Enter for " << schema << ": ";
string tmpSchema;
getline(cin, tmpSchema);
if(tmpSchema.length() > 0)
{
schema = tmpSchema;
}
// Prompt for table.
cout << "Enter Table or Enter for " << colstable << ": ";
string tmpTable;
getline(cin, tmpTable);
if(tmpTable.length() > 0)
{
colstable = tmpTable;
}
timer.start("Total");
int maxCols = 9;
cout << endl;
for(int i = 7; i <= maxCols; i++) {
cout << endl << "Running test " << i << " of " << maxCols << endl;
stringstream ss;
ss << "Delivery test for " << dataSize << " rows and " << i << " columns";
timer.start(ss.str());
deliverTest(i);
timer.stop(ss.str());
}
timer.stop("Total");
timer.finish();
}
示例2: kernel
void
EventDeliveryManager::gather_events( bool done )
{
// IMPORTANT: Ensure that gather_events(..) is called from a single thread and
// NOT from a parallel OpenMP region!!!
// Stop watch for time measurements within this function
static Stopwatch stw_local;
stw_local.reset();
stw_local.start();
collocate_buffers_( done );
stw_local.stop();
time_collocate_ += stw_local.elapsed();
stw_local.reset();
stw_local.start();
if ( off_grid_spiking_ )
{
kernel().mpi_manager.communicate(
local_offgrid_spikes_, global_offgrid_spikes_, displacements_ );
}
else
{
kernel().mpi_manager.communicate(
local_grid_spikes_, global_grid_spikes_, displacements_ );
}
stw_local.stop();
time_communicate_ += stw_local.elapsed();
}
示例3:
ADD_TEST(StopWatchTest, TestAll) {
Stopwatch sw;
sw.start();
this_thread::sleep_for(chrono::milliseconds(200));
sw.stop();
Int64 d = sw.elapsed();
CHECK(d > 180000);
CHECK(d < 300000);
sw.start();
this_thread::sleep_for(chrono::milliseconds(100));
sw.stop();
d = sw.elapsed();
CHECK(d > 280000);
CHECK(d < 400000);
this_thread::sleep_for(chrono::milliseconds(100));
sw.stop();
d = sw.elapsed();
CHECK(d > 380000);
CHECK(d < 500000);
sw.restart();
sw.start();
this_thread::sleep_for(chrono::milliseconds(200));
sw.stop();
d = sw.elapsed();
CHECK(d > 180000);
CHECK(d < 300000);
}
示例4: zdl
//--------------------------------------------------------------------------
// ZDL benchmark functions
//--------------------------------------------------------------------------
void ZDL_bench_1set_seq()
{
typedef ElementType Element;
uint i;
uint numOfProducers = NUM_PRODUCERS;
uint numOfConsumers = NUM_CONSUMERS;
ZDL<Element> zdl(numOfConsumers, fRm);
zdl.setMultipleProducers(true);
zdl.setElementMode(1); // RID_VALUE
pthread_t producer[numOfProducers];
pthread_t consumer[numOfConsumers];
ThreadParms producerThreadParms[NUM_PRODUCERS];
ThreadParms consumerThreadParms[NUM_CONSUMERS];
struct timespec ts1, ts2, diff;
timer.start("zdl-produce_1set_seq");
clock_gettime(CLOCK_REALTIME, &ts1);
for (i = 0; i < numOfProducers; i++)
{
producerThreadParms[i].zdl = &zdl;
producerThreadParms[i].threadNumber = i;
producerThreadParms[i].count = ::count1Set;
pthread_create(&producer[i], NULL,
ZDL_producer_1set_seq<Element>, &producerThreadParms[i]);
}
for (i = 0; i < numOfProducers; i++)
pthread_join(producer[i], NULL);
zdl.endOfInput();
timer.stop("zdl-produce_1set_seq");
timer.start("zdl-consume_1set_seq");
for (i = 0; i < numOfConsumers; i++)
{
consumerThreadParms[i].zdl = &zdl;
consumerThreadParms[i].threadNumber = i;
consumerThreadParms[i].count = 0;
pthread_create(&consumer[i], NULL,
ZDL_consumer<Element>, &consumerThreadParms[i]);
}
for (i = 0; i < numOfConsumers; i++)
pthread_join(consumer[i], NULL);
clock_gettime(CLOCK_REALTIME, &ts2);
timer.stop("zdl-consume_1set_seq");
timer.finish();
timespec_sub(ts1, ts2, diff);
cout << "# of Producers: " << numOfProducers << endl;
cout << "# of Consumers: " << numOfConsumers << endl;
cout << "ZDL_bench_1set_seq: producer & consumer passed " <<
zdl.totalSize() << " elements in " << diff.tv_sec << "s " <<
diff.tv_nsec << "ns" << endl;
ZDL_printFileStats<Element>(&zdl);
validateResults(::count1Set*NUM_PRODUCERS);
}
示例5: main
int main(int, char **)
try
{
std::cout << std::fixed << std::setprecision(2);
size_t n = 100000000;
Stopwatch stopwatch;
{
DB::WriteBufferFromFile buf("test_zlib_buffers.gz", DBMS_DEFAULT_BUFFER_SIZE, O_WRONLY | O_CREAT | O_TRUNC);
DB::ZlibDeflatingWriteBuffer deflating_buf(buf, DB::CompressionMethod::Gzip, /* compression_level = */ 3);
stopwatch.restart();
for (size_t i = 0; i < n; ++i)
{
DB::writeIntText(i, deflating_buf);
DB::writeChar('\t', deflating_buf);
}
deflating_buf.finish();
stopwatch.stop();
std::cout << "Writing done. Elapsed: " << stopwatch.elapsedSeconds() << " s."
<< ", " << (deflating_buf.count() / stopwatch.elapsedSeconds() / 1000000) << " MB/s"
<< std::endl;
}
{
DB::ReadBufferFromFile buf("test_zlib_buffers.gz");
DB::ZlibInflatingReadBuffer inflating_buf(buf, DB::CompressionMethod::Gzip);
stopwatch.restart();
for (size_t i = 0; i < n; ++i)
{
size_t x;
DB::readIntText(x, inflating_buf);
inflating_buf.ignore();
if (x != i)
throw DB::Exception("Failed!, read: " + std::to_string(x) + ", expected: " + std::to_string(i), 0);
}
stopwatch.stop();
std::cout << "Reading done. Elapsed: " << stopwatch.elapsedSeconds() << " s."
<< ", " << (inflating_buf.count() / stopwatch.elapsedSeconds() / 1000000) << " MB/s"
<< std::endl;
}
return 0;
}
catch (const DB::Exception & e)
{
std::cerr << e.what() << ", " << e.displayText() << std::endl;
return 1;
}
示例6: execute
static void NO_INLINE execute(const Source & data, size_t num_threads,
Creator && creator, Updater && updater, Merger && merger,
ThreadPool & pool)
{
std::vector<std::unique_ptr<Map>> intermediate_results;
Stopwatch watch;
Aggregate::execute(data, num_threads, intermediate_results, std::forward<Creator>(creator), std::forward<Updater>(updater), pool);
size_t num_maps = intermediate_results.size();
watch.stop();
double time_aggregated = watch.elapsedSeconds();
std::cerr
<< "Aggregated in " << time_aggregated
<< " (" << data.size() / time_aggregated << " elem/sec.)"
<< std::endl;
size_t size_before_merge = 0;
std::cerr << "Sizes: ";
for (size_t i = 0; i < num_threads; ++i)
{
std::cerr << (i == 0 ? "" : ", ") << intermediate_results[i]->size();
size_before_merge += intermediate_results[i]->size();
}
std::cerr << std::endl;
watch.restart();
std::vector<Map*> intermediate_results_ptrs(num_maps);
for (size_t i = 0; i < num_maps; ++i)
intermediate_results_ptrs[i] = intermediate_results[i].get();
Map * result_map;
Merge::execute(intermediate_results_ptrs.data(), num_maps, result_map, std::forward<Merger>(merger), pool);
watch.stop();
double time_merged = watch.elapsedSeconds();
std::cerr
<< "Merged in " << time_merged
<< " (" << size_before_merge / time_merged << " elem/sec.)"
<< std::endl;
double time_total = time_aggregated + time_merged;
std::cerr
<< "Total in " << time_total
<< " (" << data.size() / time_total << " elem/sec.)"
<< std::endl;
std::cerr << "Size: " << result_map->size() << std::endl << std::endl;
}
示例7: load_save
//--------------------------------------------------------------------------
// test the saving and loading of a zdl file
//--------------------------------------------------------------------------
void load_save(){
typedef ElementType Element;
vector <Element> v;
for (uint i = 0; i < ::count1Set*8; i++)
v.push_back(Element(i,i));
vector<Element> v1;
vector<Element> v2;
vector<Element> v3;
// save
ofstream f1;
ifstream f;
string filename = "zdl.txt";
uint64_t ctn = v.size();
f1.open(filename.c_str(), std::ios::binary);
f1.write((char *) &ctn, sizeof(ctn));
f1.write((char *) (v.begin().operator->()), sizeof(Element) * ctn);
f.close();
// load
v1.push_back(Element(3,4));
f.open(filename.c_str(), std::ios::binary);
timer.start("read");
v1.resize(v1.size()+::count1Set*8);
f.read((char *) ((v1.begin()+1).operator->()), ctn * sizeof(Element));
cout << v1.size() << endl;
timer.stop("read");
cout << "E1: " << v1[0].first << endl;
f.close();
f.open(filename.c_str(), std::ios::binary);
timer.start("assign");
v2.assign(std::istream_iterator<Element>(f),
std::istream_iterator<Element>());
cout << v2.size() << endl;
timer.stop("assign");
f.close();
f.open(filename.c_str(), std::ios::binary);
timer.start("insert");
v3.insert(v3.end(), std::istream_iterator<Element>(f),
std::istream_iterator<Element>());
cout << v3.size() << endl;
timer.stop("insert");
f.close();
timer.finish();
}
示例8: cmd_merge
string OriCommand::cmd_merge(strstream &str)
{
#if defined(DEBUG) || defined(ORI_PERF)
Stopwatch sw = Stopwatch();
sw.start();
#endif /* DEBUG */
FUSE_PLOG("Command: merge");
string error;
ObjectHash hash;
strwstream resp;
// Parse Command
str.readHash(hash);
RWKey::sp lock = priv->nsLock.writeLock();
error = priv->merge(hash);
lock.reset();
if (error != "") {
resp.writeUInt8(0);
resp.writePStr(error);
} else {
resp.writeUInt8(1);
}
#if defined(DEBUG) || defined(ORI_PERF)
sw.stop();
FUSE_PLOG("merge with: %s", hash.hex().c_str());
FUSE_PLOG("merge elapsed %lluus", sw.getElapsedTime());
#endif /* DEBUG */
return resp.str();
}
示例9: RunOCLMatMulForKernel
void RunOCLMatMulForKernel(
float * arg_A, size_t arg_hst_ptrA_dim1, size_t arg_hst_ptrA_dim2,
float * arg_C, size_t arg_hst_ptrC_dim1, size_t arg_hst_ptrC_dim2,
float * arg_B, size_t arg_hst_ptrB_dim1, size_t arg_hst_ptrB_dim2,
unsigned arg_wB, unsigned arg_wA, unsigned arg_hA
)
{
if (isFirstTime)
{
hst_ptrA = arg_A;
hst_ptrA_dim1 = arg_hst_ptrA_dim1;
hst_ptrA_dim2 = arg_hst_ptrA_dim2;
hst_ptrC = arg_C;
hst_ptrC_dim1 = arg_hst_ptrC_dim1;
hst_ptrC_dim2 = arg_hst_ptrC_dim2;
hst_ptrB = arg_B;
hst_ptrB_dim1 = arg_hst_ptrB_dim1;
hst_ptrB_dim2 = arg_hst_ptrB_dim2;
wB = arg_wB;
wA = arg_wA;
hA = arg_hA;
StartUpGPU();
AllocateBuffers();
cout << "$Defines " << KernelDefines << endl;
compileKernel(
"MatMulFor", "MatMulFor.cl", GetKernelCode(),
false, &MatMulForKernel, KernelDefines
);
SetArgumentsMatMulFor();
}
timer.start();
ExecMatMulFor();
cout << "$Time " << timer.stop() << endl;
}
示例10: RunOCLNBodyForKernel
void RunOCLNBodyForKernel(
float * arg_Mas, size_t arg_hst_ptrMas_dim1, float * arg_Pos,
size_t arg_hst_ptrPos_dim1, size_t arg_hst_ptrPos_dim2, float * arg_Forces,
size_t arg_hst_ptrForces_dim1, size_t arg_hst_ptrForces_dim2, size_t arg_N
)
{
if (isFirstTime)
{
hst_ptrMas = arg_Mas;
hst_ptrMas_dim1 = arg_hst_ptrMas_dim1;
hst_ptrPos = arg_Pos;
hst_ptrPos_dim1 = arg_hst_ptrPos_dim1;
hst_ptrPos_dim2 = arg_hst_ptrPos_dim2;
hst_ptrForces = arg_Forces;
hst_ptrForces_dim1 = arg_hst_ptrForces_dim1;
hst_ptrForces_dim2 = arg_hst_ptrForces_dim2;
N = arg_N;
StartUpGPU();
AllocateBuffers();
cout << "$Defines " << KernelDefines << endl;
compileKernel(
"NBodyFor", "NBodyFor.cl", GetKernelCode(),
false, &NBodyForKernel, KernelDefines
);
SetArgumentsNBodyFor();
}
timer.start();
ExecNBodyFor();
cout << "$Time " << timer.stop() << endl;
}
示例11: test
void test(size_t n, const char * name, F && kernel)
{
x = 0;
Stopwatch watch;
Stopwatch watch_one;
double max_seconds = 0;
std::cerr << name << ":\n";
for (size_t i = 0; i < n; ++i)
{
watch_one.restart();
kernel();
watch_one.stop();
if (watch_one.elapsedSeconds() > max_seconds)
max_seconds = watch_one.elapsedSeconds();
}
watch.stop();
std::cerr
<< std::fixed << std::setprecision(2)
<< n << " ops in "
<< watch.elapsedSeconds() << " sec., "
<< n / watch.elapsedSeconds() << " ops/sec., "
<< "avg latency: " << watch.elapsedSeconds() / n * 1000000 << " μs, "
<< "max latency: " << max_seconds * 1000000 << " μs "
<< "(res = " << x << ")"
<< std::endl;
}
示例12: main
int main(int argc, char** argv)
{
verbose = getenv("PEGASUS_TEST_VERBOSE") ? true : false;
Stopwatch sw;
sw.start();
System::sleep(5);
sw.stop();
double elapsed = sw.getElapsed();
if(verbose)
{
sw.printElapsed();
}
PEGASUS_TEST_ASSERT((elapsed >= 4.5) && (elapsed <= 5.5));
cout << argv[0] << " +++++ passed all tests" << endl;
return 0;
}
示例13: queuedBSBenchmark
void queuedBSBenchmark(int queueLength)
{
ByteStream *bs;
pthread_t threads[columns];
uint i, rowCount = 1;
JobStepAssociation inJs;
for (i = 0; i < columns; ++i) {
AnyDataListSPtr spdl1(new AnyDataList());
FIFO<UintRowGroup>* dl1 = new FIFO<UintRowGroup>(1, fifoSize);
dl1->OID(i); // lineitem first col object id
spdl1->fifoDL(dl1);
inJs.outAdd(spdl1);
pthread_create(&threads[i], 0, nextBandBenchProducer, dl1 );
cout << "started thread " << i << endl;
}
DeliveryStep ds(inJs, JobStepAssociation(), 8);
BSQueueMgr bsq(&ds, queueLength);
stringstream ss;
ss << "queuedBSBenchmark with " << columns << " columns and " << queueLength << " queue length\n";
timer.start(ss.str());
boost::thread(BSProjectThread(&bsq));
while (rowCount != 0) {
bs = bsq.getNextByteStream(rowCount);
delete bs;
}
timer.stop(ss.str());
for (i = 0; i < columns; ++i)
pthread_join(threads[i], NULL);
}
示例14: RunOCLNBody2ForKernel
void RunOCLNBody2ForKernel(
float * arg_Mas, size_t arg_hst_ptrMas_dim1, float * arg_Forces_y,
size_t arg_hst_ptrForces_y_dim1, size_t arg_hst_ptrForces_y_dim2, float * arg_Pos,
size_t arg_hst_ptrPos_dim1, size_t arg_hst_ptrPos_dim2, float * arg_Forces_x,
size_t arg_hst_ptrForces_x_dim1, size_t arg_hst_ptrForces_x_dim2, size_t arg_N
)
{
if (isFirstTime)
{
hst_ptrMas = arg_Mas;
hst_ptrMas_dim1 = arg_hst_ptrMas_dim1;
hst_ptrForces_y = arg_Forces_y;
hst_ptrForces_y_dim1 = arg_hst_ptrForces_y_dim1;
hst_ptrForces_y_dim2 = arg_hst_ptrForces_y_dim2;
hst_ptrPos = arg_Pos;
hst_ptrPos_dim1 = arg_hst_ptrPos_dim1;
hst_ptrPos_dim2 = arg_hst_ptrPos_dim2;
hst_ptrForces_x = arg_Forces_x;
hst_ptrForces_x_dim1 = arg_hst_ptrForces_x_dim1;
hst_ptrForces_x_dim2 = arg_hst_ptrForces_x_dim2;
N = arg_N;
StartUpGPU();
AllocateBuffers();
compileKernelFromFile(
"NBody2For", "NBody2For.cl", KernelString(),
true, &NBody2ForKernel, KernelDefines
);
SetArgumentsNBody2For();
}
timer.start();
ExecNBody2For();
cout << timer.stop() << endl;
}
示例15: walk_tree
void walk_tree()
{
static Stopwatch timer;
timer.start();
scale_factor = sqrt(2.0*pow(((double)width/(bbmax-bbmin).max()), 2.0));
vert_ls splats = sphere_tree->recurseToDepth(recursion_depth);
splats.sort(testSize);
maxSplatSize = scale_factor * (splats.front()->size - splats.back()-> size)/2.0;
fastSplats.clear();
fastSplats.reserve(splats.size());
for (vert_it it = splats.begin(); it != splats.end(); it++)
{
fastSplats.push_back(**it);
}
splatParts.clear();
splatSizes.clear();
partitionSizes(fastSplats.begin(), fastSplats.end(), 5);
splatParts.push_back(fastSplats.end());
cout << splatSizes.size() << endl;
timer.stop();
printf("Recursed to depth %u in %f seconds\n", recursion_depth, timer.time());
printf("Displaying %lu splats, with %lu sizes\n", splats.size(), splatSizes.size() );
timer.reset();
}