当前位置: 首页>>代码示例>>C++>>正文


C++ Stopwatch::start方法代码示例

本文整理汇总了C++中Stopwatch::start方法的典型用法代码示例。如果您正苦于以下问题:C++ Stopwatch::start方法的具体用法?C++ Stopwatch::start怎么用?C++ Stopwatch::start使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Stopwatch的用法示例。


在下文中一共展示了Stopwatch::start方法的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();
}
开发者ID:Kangmo,项目名称:infinidb,代码行数:39,代码来源:tdriver-deliver.cpp

示例2:

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);
}
开发者ID:jaejungkim,项目名称:MonaServer,代码行数:31,代码来源:StopWatchTest.cpp

示例3: 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();
}
开发者ID:DimitriPlotnikov,项目名称:nest-simulator,代码行数:29,代码来源:event_delivery_manager.cpp

示例4: testTimerHandler

void testTimerHandler()
{
	LOGT("<testTimerHandler>");

	Timer t1, t2;
	TimerHandler handler;
	handler.attach(t1, timeout1);
	handler.attach(t2, timeout2);

	t1.setInterval(1);
	t2.setInterval(2);

	sw1.start();
	sw2.start();

	t1.start();
	t2.start();

	Thread::sleep(15);
	handler.detach(t2);
	Thread::sleep(30);

	t1.stop();
	t2.stop();

	Thread::sleep(105);
}
开发者ID:CltKitakami,项目名称:MyLib,代码行数:27,代码来源:TestTimer.cpp

示例5: 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);
	}
开发者ID:Kangmo,项目名称:infinidb,代码行数:59,代码来源:tdriver-zdl.cpp

示例6: 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();
    }
开发者ID:Kangmo,项目名称:infinidb,代码行数:52,代码来源:tdriver-zdl.cpp

示例7: 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);
}
开发者ID:Kangmo,项目名称:infinidb,代码行数:35,代码来源:tdriver-deliver.cpp

示例8: atScopeExit

    std::int64_t OneToOneSequencedBatchThroughputTest::run(Stopwatch& stopwatch)
    {
        m_taskScheduler->start(requiredProcessorCount());
        TestTools::ScopeExitFunctor atScopeExit([this] { m_taskScheduler->stop(); });

        auto signal = std::make_shared< Tests::ManualResetEvent >(false);
        auto expectedCount = m_batchEventProcessor->sequence()->value() + m_iterations * m_batchSize;
        m_handler->reset(signal, expectedCount);
        auto processorTask = m_executor->execute([this] { m_batchEventProcessor->run(); });
        stopwatch.start();

        auto&& rb = *m_ringBuffer;

        for (auto i = 0; i < m_iterations; ++i)
        {
            auto hi = rb.next(m_batchSize);
            auto lo = hi - (m_batchSize - 1);
            for (auto l = lo; l <= hi; ++l)
            {
                rb[l].value = (i);
            }
            rb.publish(lo, hi);
        }

        signal->waitOne();
        stopwatch.stop();
        PerfTestUtil::waitForEventProcessorSequence(expectedCount, m_batchEventProcessor);
        m_batchEventProcessor->halt();
        processorTask.wait_for(std::chrono::milliseconds(2000));

        PerfTestUtil::failIfNot(m_expectedResult, m_handler->value(),
                                "Handler should have processed " + std::to_string(m_expectedResult) + " events, but was: " + std::to_string(m_handler->value()));

        return m_batchSize * m_iterations;
    }
开发者ID:castramet,项目名称:Disruptor-cpp,代码行数:35,代码来源:OneToOneSequencedBatchThroughputTest.cpp

示例9: await

bool await(const process::Future<T>& future, const Duration& duration)
{
  if (!process::Clock::paused()) {
    return future.await(duration);
  }

  // If the clock is paused, no new timers will expire.
  // Future::await(duration) may hang forever because it depends on
  // a timer to expire after 'duration'. We instead ensure all
  // expired timers are flushed and check if the future is satisfied.
  Stopwatch stopwatch;
  stopwatch.start();

  // Settle to make sure all expired timers are executed (not
  // necessarily finished, see below).
  process::Clock::settle();

  while (future.isPending() && stopwatch.elapsed() < duration) {
    // Synchronous operations and asynchronous process::Process
    // operations should finish when the above 'settle()' returns.
    // Other types of async operations such as io::write() may not.
    // Therefore we wait the specified duration for it to complete.
    // Note that nothing prevents the operations to schedule more
    // timeouts for some time in the future. These timeouts will
    // never be executed due to the paused process::Clock. In this
    // case we return after the stopwatch (system clock) runs out.
    os::sleep(Milliseconds(10));
  }

  return !future.isPending();
}
开发者ID:vanloswang,项目名称:mesos,代码行数:31,代码来源:gtest.hpp

示例10: run

    void PingPongSequencedLatencyTest::run(Stopwatch& stopwatch, const std::shared_ptr< Tests::LatencyRecorder >& latencyRecorder)
    {
        m_taskScheduler->start(requiredProcessorCount());
        TestTools::ScopeExitFunctor atScopeExit([this] { m_taskScheduler->stop(); });

        auto globalSignal = std::make_shared< Tests::CountdownEvent >(3);
        auto signal = std::make_shared< Tests::ManualResetEvent >(false);
        m_pinger->reset(globalSignal, signal, latencyRecorder);
        m_ponger->reset(globalSignal);

        auto processorTask1 = m_executor->execute([this] { m_pongProcessor->run(); });
        auto processorTask2 = m_executor->execute([this] { m_pingProcessor->run(); });

        globalSignal->signal();
        globalSignal->wait();
        stopwatch.start();
        // running here
        signal->waitOne();
        stopwatch.stop();

        m_pingProcessor->halt();
        m_pongProcessor->halt();

        processorTask1.wait();
        processorTask2.wait();
    }
开发者ID:castramet,项目名称:Disruptor-cpp,代码行数:26,代码来源:PingPongSequencedLatencyTest.cpp

示例11: resourceOffers

  void resourceOffers(const vector<Offer>& offers,
                      const vector<string>& pids)
  {
    if (aborted) {
      VLOG(1) << "Ignoring resource offers message because "
              << "the driver is aborted!";
      return;
    }

    VLOG(2) << "Received " << offers.size() << " offers";

    CHECK(offers.size() == pids.size());

    // Save the pid associated with each slave (one per offer) so
    // later we can send framework messages directly.
    for (size_t i = 0; i < offers.size(); i++) {
      UPID pid(pids[i]);
      // Check if parse failed (e.g., due to DNS).
      if (pid != UPID()) {
        VLOG(3) << "Saving PID '" << pids[i] << "'";
        savedOffers[offers[i].id()][offers[i].slave_id()] = pid;
      } else {
        VLOG(1) << "Failed to parse PID '" << pids[i] << "'";
      }
    }

    Stopwatch stopwatch;
    if (FLAGS_v >= 1) {
      stopwatch.start();
    }

    scheduler->resourceOffers(driver, offers);

    VLOG(1) << "Scheduler::resourceOffers took " << stopwatch.elapsed();
  }
开发者ID:iopenstack,项目名称:mesos,代码行数:35,代码来源:sched.cpp

示例12: doFollyDynamic

void doFollyDynamic(std::vector<std::string> strvec) 
{
	std::cout << "folly::dynamic" << std::endl;
	std::cout << "==============" << std::endl;

	std::vector<std::string>::iterator it = strvec.begin();
	std::vector<std::string>::iterator end = strvec.end();

	Stopwatch sw;
	sw.start();
	for (; it != end; ++it)
	{
		dynamic var(*it);
		
		int i = var.asInt();
	
		double d = var.asDouble();

		var = i;
		std::string s = var.asString().c_str();

		var = d;
		s = var.asString().c_str();
	}
	sw.stop();
	std::cout << "folly::dynamic: " << sw.elapsed()/1000.0 << " [ms]" << std::endl;
	
	std::cout << "==============" << std::endl;
}
开发者ID:aleks-f,项目名称:articles,代码行数:29,代码来源:folly_dynamic.cpp

示例13: main

int main()
{
    Stopwatch sw;

    sw.start();

	size_t n = 600851475143;
    size_t z = n;
	vector<size_t> factors;

    size_t s = static_cast<size_t>(sqrt(n));
    for (size_t i = 2; i <= s; i++) {
        if (z % i == 0) {
            factors.push_back(i);
            z /= i;
            i = 2;
        }
        if (i == s && z != 1) {
            factors.push_back(z);
        }
    }

    cout << strjoin(factors, " * ") << endl;
    cout << sw.get();
	return 0;
}
开发者ID:andi-d,项目名称:project-euler,代码行数:26,代码来源:main.cpp

示例14: curves

auto_release_ptr<CurveObject> CurveObjectReader::load_curve_file(
    const SearchPaths&      search_paths,
    const char*             name,
    const ParamArray&       params)
{
    auto_release_ptr<CurveObject> object = CurveObjectFactory::create(name, params);

    const string filepath = search_paths.qualify(params.get<string>("filepath"));
    const size_t split_count = params.get_optional<size_t>("presplits", 0);

    ifstream input;
    input.open(filepath.c_str());

    if (!input.is_open())
    {
        RENDERER_LOG_ERROR("failed to open curve file %s.", filepath.c_str());
        return object;
    }

    Stopwatch<DefaultWallclockTimer> stopwatch;
    stopwatch.start();

    size_t curve1_count;
    size_t curve3_count;
    input >> curve1_count;
    input >> curve3_count;

    object->reserve_curves1(curve1_count);
    object->reserve_curves3(curve3_count);

    for (size_t c = 0; c < curve1_count + curve3_count; ++c)
    {
        size_t control_point_count;
        input >> control_point_count;

        if (control_point_count != 2 && control_point_count != 4)
        {
            RENDERER_LOG_ERROR(
                "while loading curve file %s: only linear curves (2 control points) or cubic curves (4 control points) are currently supported.",
                filepath.c_str());
            return object;
        }

        if (control_point_count == 2)
        {
            GVector3 points[2];
            GScalar widths[2];

            for (size_t p = 0; p < control_point_count; ++p)
            {
                input >> points[p].x >> points[p].y >> points[p].z;
                input >> widths[p];
            }

            // We never presplit degree-1 curves.
            const CurveType1 curve(points, widths);
            object->push_curve1(curve);
        }
        else
        {
开发者ID:camargo,项目名称:appleseed,代码行数:60,代码来源:curveobjectreader.cpp

示例15: message_context

CurveTree::CurveTree(const Arguments& arguments)
  : TreeType(AlignedAllocator<void>(System::get_l1_data_cache_line_size()))
  , m_arguments(arguments)
{
    // Retrieve construction parameters.
    const MessageContext message_context(
        format("while building curve tree for assembly \"{0}\"", m_arguments.m_assembly.get_path()));
    const ParamArray& params = m_arguments.m_assembly.get_parameters().child("acceleration_structure");
    const string algorithm = params.get_optional<string>("algorithm", "bvh", make_vector("bvh", "sbvh"), message_context);
    const double time = params.get_optional<double>("time", 0.5);

    // Start stopwatch.
    Stopwatch<DefaultWallclockTimer> stopwatch;
    stopwatch.start();

    // Build the tree.
    Statistics statistics;
    if (algorithm == "bvh")
        build_bvh(params, time, statistics);
    else throw ExceptionNotImplemented();

    // Print curve tree statistics.
    statistics.insert_size("nodes alignment", alignment(&m_nodes[0]));
    statistics.insert_time("total time", stopwatch.measure().get_seconds());
    RENDERER_LOG_DEBUG("%s",
        StatisticsVector::make(
            "curve tree #" + to_string(m_arguments.m_curve_tree_uid) + " statistics",
            statistics).to_string().c_str());
}
开发者ID:,项目名称:,代码行数:29,代码来源:


注:本文中的Stopwatch::start方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。