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


C++ Stopwatch类代码示例

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


在下文中一共展示了Stopwatch类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: error

  void error(const string& message)
  {
    if (aborted) {
      VLOG(1) << "Ignoring error message because the driver is aborted!";
      return;
    }

    VLOG(1) << "Got error '" << message << "'";

    driver->abort();

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

    scheduler->error(driver, message);

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

示例2: statusUpdate

  void statusUpdate(const StatusUpdate& update, const UPID& pid)
  {
    const TaskStatus& status = update.status();

    if (aborted) {
      VLOG(1) << "Ignoring task status update message because "
              << "the driver is aborted!";
      return;
    }

    VLOG(2) << "Received status update " << update << " from " << pid;

    CHECK(framework.id() == update.framework_id());

    // TODO(benh): Note that this maybe a duplicate status update!
    // Once we get support to try and have a more consistent view
    // of what's running in the cluster, we'll just let this one
    // slide. The alternative is possibly dealing with a scheduler
    // failover and not correctly giving the scheduler it's status
    // update, which seems worse than giving a status update
    // multiple times (of course, if a scheduler re-uses a TaskID,
    // that could be bad.

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

    scheduler->statusUpdate(driver, status);

    VLOG(1) << "Scheduler::statusUpdate took " << stopwatch.elapsed();

    // Acknowledge the status update.
    // NOTE: We do a dispatch here instead of directly sending the ACK because,
    // we want to avoid sending the ACK if the driver was aborted when we
    // made the statusUpdate call. This works because, the 'abort' message will
    // be enqueued before the ACK message is processed.
    if (pid > 0) {
      dispatch(self(), &Self::statusUpdateAcknowledgement, update, pid);
    }
  }
开发者ID:iopenstack,项目名称:mesos,代码行数:41,代码来源:sched.cpp

示例3: assert

bool MeshObjectWriter::write(
    const MeshObject&   object,
    const char*         object_name,
    const char*         filename)
{
    assert(filename);

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

    try
    {
        OBJMeshFileWriter writer(filename);
        MeshObjectWalker walker(object, object_name);
        writer.write(walker);
    }
    catch (const ExceptionIOError&)
    {
        RENDERER_LOG_ERROR(
            "failed to write mesh file %s: i/o error.",
            filename);
        return false;
    }
    catch (const Exception& e)
    {
        RENDERER_LOG_ERROR(
            "failed to write mesh file %s: %s.",
            filename,
            e.what());
        return false;
    }

    stopwatch.measure();

    RENDERER_LOG_INFO(
        "wrote mesh file %s in %s.",
        filename,
        pretty_time(stopwatch.get_seconds()).c_str());

    return true;
}
开发者ID:EgoIncarnate,项目名称:appleseed,代码行数:41,代码来源:meshobjectwriter.cpp

示例4: defined

string OriCommand::cmd_status(strstream &str)
{
#if defined(DEBUG) || defined(ORI_PERF)
    Stopwatch sw = Stopwatch();
    sw.start();
#endif /* DEBUG */

    FUSE_PLOG("Command: status");

    map<string, OriFileState::StateType> diff;
    map<string, OriFileState::StateType>::iterator it;
    strwstream resp;

    RWKey::sp lock = priv->nsLock.writeLock();
    diff = priv->getDiff();
    lock.reset();

    resp.writeUInt32(diff.size());
    for (it = diff.begin(); it != diff.end(); it++) {
        char type = '!';

        if (it->second == OriFileState::Created)
            type = 'A';
        else if (it->second == OriFileState::Modified)
            type = 'M';
        else if (it->second == OriFileState::Deleted)
            type = 'D';
        else
            ASSERT(false);

        resp.writeUInt8(type);
        resp.writeLPStr(it->first);
    }

#if defined(DEBUG) || defined(ORI_PERF)
    sw.stop();
    FUSE_PLOG("status elapsed %lluus", sw.getElapsedTime());
#endif /* DEBUG */

    return resp.str();
}
开发者ID:ailidani,项目名称:dfs,代码行数:41,代码来源:oricmd.cpp

示例5: rescindOffer

  void rescindOffer(const OfferID& offerId)
  {
    if (aborted) {
      VLOG(1) << "Ignoring rescind offer message because "
              << "the driver is aborted!";
      return;
    }

    VLOG(1) << "Rescinded offer " << offerId;

    savedOffers.erase(offerId);

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

    scheduler->offerRescinded(driver, offerId);

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

示例6: run

void Encode::run()
{
    Stopwatch stopwatch;

    while (next_block())
        process_block();

    stopwatch.stop("[runtime]");

    printf("\n");
    vmpeak(stdout);

    printf("\n");
    printf("output.nomatch      : %zu (%.2f%%)\n", output.nomatch, (output.nomatch/(double)input.nreads)*100.0);
    printf("output.fullmatch    : %zu (%.2f%%)\n", output.nfullmatch, (output.nfullmatch/(double)input.nreads)*100.0);
    printf("output.nrcomplement : %zu (%.2f%%)\n", output.nrcomplement, (output.nrcomplement/(double)input.nreads)*100.0);
    printf("output.nbits        : %zu\n", output.nbits);
    printf("output.nbytes       : %zu (%.2f MB)\n", output.nbits / 8, output.nbits / 8.0 / 1e6);
    printf("output.compression  : %.2f%%\n", ((output.nbits/8.0)/input.nbytes)*100.0);
    printf("\n");
}
开发者ID:tkind94,项目名称:afin---faust,代码行数:21,代码来源:faust-encode.cpp

示例7: execute

    void execute(ConnectionPool::Entry & connection, Query & query)
    {
        Stopwatch watch;
        RemoteBlockInputStream stream(*connection, query, &settings, nullptr, Tables(), query_processing_stage);

        Progress progress;
        stream.setProgressCallback([&progress](const Progress & value) { progress.incrementPiecewiseAtomically(value); });

        stream.readPrefix();
        while (Block block = stream.read())
            ;
        stream.readSuffix();

        const BlockStreamProfileInfo & info = stream.getProfileInfo();

        double seconds = watch.elapsedSeconds();

        std::lock_guard<std::mutex> lock(mutex);
        info_per_interval.add(seconds, progress.rows, progress.bytes, info.rows, info.bytes);
        info_total.add(seconds, progress.rows, progress.bytes, info.rows, info.bytes);
    }
开发者ID:yurial,项目名称:ClickHouse,代码行数:21,代码来源:Benchmark.cpp

示例8: frameworkMessage

  void frameworkMessage(const SlaveID& slaveId,
                        const FrameworkID& frameworkId,
                        const ExecutorID& executorId,
                        const string& data)
  {
    if (aborted) {
      VLOG(1) << "Ignoring framework message because the driver is aborted!";
      return;
    }

    VLOG(2) << "Received framework message";

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

    scheduler->frameworkMessage(driver, executorId, slaveId, data);

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

示例9: main

int main(int argc, char** argv)
{
#ifdef PARALLEL_CORES
  omp_set_num_threads(PARALLEL_CORES);
#endif

  OpenANN::Logger resultLogger(OpenANN::Logger::CONSOLE);
  const int architectures = 6;
  const int runs = 100;
  OpenANN::StoppingCriteria stop;
  stop.minimalSearchSpaceStep = 1e-16;
  stop.minimalValueDifferences = 1e-16;
  stop.maximalIterations = 10000;
  Stopwatch sw;

  Eigen::MatrixXd Xtr, Ytr, Xte, Yte;
  createTwoSpiralsDataSet(2, 1.0, Xtr, Ytr, Xte, Yte);

  for(int architecture = 0; architecture < architectures; architecture++)
  {
    long unsigned time = 0;
    std::vector<Result> results;
    OpenANN::Net net;
    setup(net, architecture);
    for(int run = 0; run < runs; run++)
    {
      EvaluatableDataset ds(Xtr, Ytr);
      net.trainingSet(ds);
      sw.start();
      OpenANN::train(net, "LMA", OpenANN::SSE, stop, true);
      time += sw.stop(Stopwatch::MILLISECOND);
      Result result = evaluate(net, Xte, Yte, ds);
      results.push_back(result);
      resultLogger << ".";
    }
    resultLogger << "\nFinished " << runs << " runs.\n";
    logResults(results, time);
  }
  return EXIT_SUCCESS;
}
开发者ID:CreativelyMe,项目名称:OpenANN,代码行数:40,代码来源:twospirals.cpp

示例10: stopTaskSchedulerAtScopeExit

    std::int64_t OneToOneTranslatorThroughputTest::run(Stopwatch& stopwatch)
    {
        m_taskScheduler = std::make_shared< RoundRobinThreadAffinedTaskScheduler >();
        m_taskScheduler->start(requiredProcessorCount());
        TestTools::ScopeExitFunctor stopTaskSchedulerAtScopeExit([this] { m_taskScheduler->stop(); });

        m_disruptor = std::make_shared< ::Disruptor::disruptor< ValueEvent > >(ValueEvent::eventFactory(),
                                                                                  m_bufferSize,
                                                                                  m_taskScheduler,
                                                                                  ProducerType::Single,
                                                                                  std::make_shared< YieldingWaitStrategy >());
        TestTools::ScopeExitFunctor stopDisruptorAtScopeExit([this] { m_disruptor->shutdown(std::chrono::seconds(10)); });

        m_disruptor->handleEventsWith(m_handler);
        m_ringBuffer = m_disruptor->start();

        auto& value = m_value;

        auto latch = std::make_shared< Tests::ManualResetEvent >(false);
        auto expectedCount = m_ringBuffer->getMinimumGatingSequence() + m_iterations;

        m_handler->reset(latch, expectedCount);
        stopwatch.start();

        auto& rb = *m_ringBuffer;

        for (std::int64_t l = 0; l < m_iterations; ++l)
        {
            value.value = l;
            rb.publishEvent(Translator::instance(), value);
        }

        latch->waitOne();
        stopwatch.stop();
        waitForEventProcessorSequence(expectedCount);

        PerfTestUtil::failIfNot(m_expectedResult, m_handler->value());

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

示例11: doVariant

void doVariant(const std::vector<std::string>& strvec)
{
	MyObj o;

	std::cout << sizeof(o) << std::endl;
	boost::variant<std::string, double> u(1.1);
	/*
	std::cout << "boost::variant" << std::endl;
	std::cout << "==============" << std::endl;
	
	printSize<char>();
	printSize<int>();
	printSize<float>();
	printSize<double>();
	printSize<std::string>();
	*/
	std::vector<std::string>::const_iterator it = strvec.begin();
	std::vector<std::string>::const_iterator end = strvec.end();

	Stopwatch sw;
	sw.start();
	for (; it != end; ++it)
	{
		boost::variant<int, double, std::string> u(*it);
		
		int i = boost::apply_visitor(string_int_converter(), u);
	
		double d = boost::apply_visitor(string_dbl_converter(), u);

		u = i;
		std::string s = boost::apply_visitor(num_string_converter(), u);

		u = d;
		s = boost::apply_visitor(num_string_converter(), u);
	}
	sw.stop();
	std::cout << "variant: " << sw.elapsed()/1000.0 << " [ms]" << std::endl;
	
	std::cout << "==============" << std::endl;
}
开发者ID:aleks-f,项目名称:articles,代码行数:40,代码来源:variant.cpp

示例12: updateGeom

//------------------------------------------------------------------------------
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);
}
开发者ID:mbdriscoll,项目名称:OpenSubdiv,代码行数:56,代码来源:viewer.cpp

示例13: approximate

void DouglasPeuckerApproximation::approximate(const std::vector <FrameWithId>& in,
        std::vector <FrameWithId>& out, double epsilon) {

#ifdef DEBUG
    Stopwatch stopwatch;
    stopwatch.start();
#endif
    std::vector <FrameWithId> inputCopy;
    inputCopy = in;
    out.clear();
    int counter = 0;
    douglasPeucker(inputCopy, out, counter, epsilon);
#ifdef DEBUG_0
    stopwatch.stop();
    LOG("Douglas-Peucker approximation algorithm:");
    LOG("  - input size: %u", inputCopy.size());
    LOG("  - epsilon: %f", epsilon);
    LOG("  - output size: %u", out.size());
    LOG("  - iterations : %d", counter);
    LOG("  - duration : %f ms", stopwatch.getElapsedTime());
#endif
}
开发者ID:BjoKaSH,项目名称:BRICS_RN,代码行数:22,代码来源:DouglasPeuckerApproximation.cpp

示例14: lock_exec

void BackgroundSchedulePool::TaskInfo::execute()
{
    Stopwatch watch;
    CurrentMetrics::Increment metric_increment{CurrentMetrics::BackgroundSchedulePoolTask};

    std::lock_guard lock_exec(exec_mutex);

    {
        std::lock_guard lock_schedule(schedule_mutex);

        if (deactivated)
            return;

        scheduled = false;
        executing = true;
    }

    function();
    UInt64 milliseconds = watch.elapsedMilliseconds();

    /// If the task is executed longer than specified time, it will be logged.
    static const int32_t slow_execution_threshold_ms = 200;

    if (milliseconds >= slow_execution_threshold_ms)
        LOG_TRACE(&Logger::get(log_name), "Execution took " << milliseconds << " ms.");

    {
        std::lock_guard lock_schedule(schedule_mutex);

        executing = false;

        /// In case was scheduled while executing (including a scheduleAfter which expired) we schedule the task
        /// on the queue. We don't call the function again here because this way all tasks
        /// will have their chance to execute

        if (scheduled)
            pool.queue.enqueueNotification(new TaskNotification(shared_from_this()));
    }
}
开发者ID:chipitsine,项目名称:ClickHouse,代码行数:39,代码来源:BackgroundSchedulePool.cpp

示例15: failed

TestCase * Grader07::testStringSort(std::string input_filename)
{
  std::vector<std::string> input;
  std::vector<std::string> output;

  Commands07 cmds07;
  cmds07.readReads(input_filename, input);
  cmds07.readReads(input_filename, output);

  if(input.size() == 0){
    return failed("cannot read input file #1");
  }  
  
  if(output.size() == 0){
    return failed("cannot read input file #2");
  }  

  Stopwatch watch;
  watch.start();

  IStringSort * sorter = (IStringSort *) createObject("IStringSort");
  if(sorter == NULL){
    return nullObject("IStringSort");
  }

  sorter->sort(input);
  watch.stop();
  
  std::sort(output.begin(), output.end());

  if(input.size() != output.size()){
    return failed("incorrect size");
  }
  if(input != output){
    return failed("at least one incorrect string");
  }

  return passed(watch.getTime());
}
开发者ID:suryak,项目名称:Advanced-Data-Structures,代码行数:39,代码来源:Grader07.cpp


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