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


C++ Stats::add方法代码示例

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


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

示例1: main

int main() {
    const int n {5};
    double data[n] {1.2, 2.3, 3.4, 4.5, 5.6};
    Stats stats;
    for (int i = 0; i < n; i++)
        stats.add(data[i]);
    std::cout << "average = " << stats.avg() << " for "
              << stats.n() << " data points" << std::endl;
    return 0;
}
开发者ID:gjbex,项目名称:training-material,代码行数:10,代码来源:stats_main.cpp

示例2: add

 void add(StatsData &d, bool enable_first, bool enable_last) {
     if (first_latency_ms == NULL) {
         initStats(enable_first, enable_last);
     }
     if (first_latency_ms) {
         first_latency_ms->add(*d.first_latency_ms);
     }
     if (last_latency_ms) {
         last_latency_ms->add(*d.last_latency_ms);
     }
     duplicates->add(*d.duplicates);
 }
开发者ID:dataseries,项目名称:DataSeries,代码行数:12,代码来源:ServerLatency.cpp

示例3: 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

示例4: main

int main() {
    double value;
    Stats stats;
    while (std::cin >> value) {
        stats.add(value);
    }
    try {
        std::cout << "mean: " << stats.mean() << std::endl;
        std::cout << "stddev: " << stats.stddev() << std::endl;
        std::cout << "min: " << stats.min() << std::endl;
        std::cout << "max: " << stats.max() << std::endl;
        std::cout << "median: " << stats.median() << std::endl;
        std::cout << "n: " << stats.nr_values() << std::endl;
    } catch (std::out_of_range& e) {
        std::cerr << "### error: " << e.what() << std::endl;
        std::exit(1);
    }
    return 0;
}
开发者ID:gjbex,项目名称:training-material,代码行数:19,代码来源:stats_main.cpp

示例5: worker

// worker requests items from the queue which are either file or
// directory paths. If item is
// 1) a filepath: computes and prints the hash of the file
// 2) a directory path: adds contained files and directories contained to
//    the queue
void worker(StringQueue& fileQueue, const Printer& printer, RefData& rd,
  Stats& stats, CmdLineOpts& opts) {

  // if we receive a non-empty refMap we compare against it
  bool compare = false;
  if (!rd.refMap.empty()) {
    compare = true;
  }

  while (!fileQueue.done()) {
    auto path = fileQueue.try_and_wait();
    if (path.empty()) {
      break;
    }

    // check if path is a directory or a file
    struct stat info;
    if (lstat(path.c_str(), &info) < 0) {
      printer.cerr("lstat failed on " + path);
      continue;
    }
    if (S_ISREG(info.st_mode)) {
      std::string hash = hasher(opts.hashMethod, path);
      if (opts.collectStats) {
        stats.add(info.st_size);
      }
      if (compare) {
        compare_to_reference(path, hash, printer, rd);
      } else {
        printer.cout(opts.hashMethod + " , " + path + " , " + hash);
      }
    } else if (S_ISDIR(info.st_mode)) {
      add_directory(fileQueue, path, printer);
    }
  }
}
开发者ID:haskelladdict,项目名称:phantom,代码行数:41,代码来源:worker.cpp

示例6: main

int main()
{
  {
    Stats stats(empty_usage, -1, empty_args);
    stats.add(empty_usage, 0, empty_args);
    assert(stats.buffer_max == 1);
    assert(stats.options_max == 1);
    Option buffer[stats.buffer_max];
    Option options[stats.options_max];
    Parser parse(empty_usage, 99, empty_args, options, buffer);
    parse.parse(empty_usage, -1, empty_args, options, buffer);
    assert(parse.optionsCount() == 0);
    assert(parse.nonOptionsCount() == 0);
    assert(!buffer[0]);
    assert(!options[0]);
    assert(buffer[0].count()==0);
    assert(parse.nonOptions()==0);

    stats.add(empty_usage, 3, non_options);
    assert(stats.buffer_max == 1);
    assert(stats.options_max == 1);
    parse.parse(empty_usage, 3, non_options, options, buffer);
    assert(parse.optionsCount() == 0);
    assert(parse.nonOptionsCount() == 3);
    assert(!buffer[0]);
    assert(!options[0]);
    assert(parse.nonOptions()==&non_options[0]);

    stats.add(minimal_usage, -1, unknown_option);
    assert(stats.buffer_max == 1);
    assert(stats.options_max == 2);
    parse.parse(minimal_usage, -1, unknown_option, options, buffer);
    assert(parse.optionsCount() == 0);
    assert(parse.nonOptionsCount() == 1);
    assert(!buffer[0]);
    assert(!options[0]);
    assert(parse.nonOptions()==&unknown_option[1]);
  }
  {
    Stats stats(gettext_usage, -1, lone_minus);
    Stats stats2;
    stats2.add(gettext_usage, -1, lone_minus);
    assert(stats.buffer_max == 2);
    assert(stats.options_max == 2);
    assert(stats2.buffer_max == 2);
    assert(stats2.options_max == 2);
    Option buffer[stats.buffer_max];
    Option options[stats.options_max];
    Parser parse;
    parse.parse(gettext_usage, -1, lone_minus, options, buffer);
    assert(parse.optionsCount() == 1);
    assert(parse.nonOptionsCount() == 1);
    assert(parse.nonOptions()==&lone_minus[2]);
    assert(options[0]);
    assert(buffer[0]);
    assert(options[0].count()==1);
    assert(options[0].isFirst());
    assert(options[0].isLast());
    assert(options[0].first() == options[0]);
    assert(options[0].last() == options[0]);
    assert(options[0].prevwrap() == &options[0]);
    assert(options[0].nextwrap() == &options[0]);
    assert(options[0].prev() == 0);
    assert(options[0].next() == 0);
    assert(options[0].desc == &gettext_usage[0]);
    assert(eq(options[0].name, "f"));
    assert(eq(options[0].arg, "-"));
  }
  {
    Stats stats(optional_usage, -1, lone_minus);
    Stats stats2;
    stats2.add(optional_usage, -1, lone_minus);
    assert(stats.buffer_max == 2);
    assert(stats.options_max == 2);
    assert(stats2.buffer_max == 2);
    assert(stats2.options_max == 2);
    Option buffer[stats.buffer_max];
    Option options[stats.options_max];
    Parser parse;
    parse.parse(optional_usage, -1, lone_minus, options, buffer);
    assert(parse.optionsCount() == 1);
    assert(parse.nonOptionsCount() == 1);
    assert(parse.nonOptions()==&lone_minus[2]);
    assert(options[0]);
    assert(buffer[0]);
    assert(options[0].count()==1);
    assert(options[0].isFirst());
    assert(options[0].isLast());
    assert(options[0].first() == options[0]);
    assert(options[0].last() == options[0]);
    assert(options[0].prevwrap() == &options[0]);
    assert(options[0].nextwrap() == &options[0]);
    assert(options[0].prev() == 0);
    assert(options[0].next() == 0);
    assert(options[0].desc == &optional_usage[0]);
    assert(eq(options[0].name, "f"));
    assert(eq(options[0].arg, "-"));
  }
  {
    Stats stats;
//.........这里部分代码省略.........
开发者ID:cbutakoff,项目名称:tools,代码行数:101,代码来源:testparse.cpp


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