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


C++ BenchmarkSuspender类代码示例

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


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

示例1: writeBench

void writeBench(size_t iter) {
  BenchmarkSuspender susp;
  auto strct = create<Struct>();
  susp.dismiss();
  while (iter--) {
    IOBufQueue q;
    Serializer::serialize(strct, &q);
    folly::doNotOptimizeAway(q);
  }
  susp.rehire();
}
开发者ID:facebook,项目名称:fbthrift,代码行数:11,代码来源:ThriftVsProtoBufBench.cpp

示例2: writeBench

void writeBench(size_t iters) {
  BenchmarkSuspender susp;
  auto strct = create<Struct>();
  susp.dismiss();

  while (iters--) {
    IOBufQueue q;
    Serializer::serialize(strct, &q);
  }
  susp.rehire();
}
开发者ID:ConfusedReality,项目名称:pkg_serialization_fbthrift,代码行数:11,代码来源:ProtocolBench.cpp

示例3: readBench

void readBench(size_t iters) {
  BenchmarkSuspender susp;
  auto strct = create<Struct>();
  IOBufQueue q;
  Serializer::serialize(strct, &q);
  auto buf = q.move();
  susp.dismiss();

  while (iters--) {
    Struct data;
    Serializer::deserialize(buf.get(), data);
  }
  susp.rehire();
}
开发者ID:ConfusedReality,项目名称:pkg_serialization_fbthrift,代码行数:14,代码来源:ProtocolBench.cpp

示例4: readBench

void readBench(size_t iter) {
  BenchmarkSuspender susp;
  auto strct = create<Struct>();
  string s;
  strct.SerializeToString(&s);

  susp.dismiss();

  while (iter--) {
    Struct data;
    data.ParseFromString(s);
    folly::doNotOptimizeAway(data);
  }
  susp.rehire();
}
开发者ID:facebook,项目名称:fbthrift,代码行数:15,代码来源:ThriftVsProtoBufBench.cpp

示例5: observe

void observe(uint iters, int N) {
  for (uint iter = 0; iter < iters; iter++) {
    BenchmarkSuspender bs;
    Subject<int> subject;
    std::vector<std::unique_ptr<Observer<int>>> observers;
    for (int i = 0; i < N; i++) {
      observers.push_back(makeObserver());
    }
    bs.dismiss();
    for (int i = 0; i < N; i++) {
      subject.observe(std::move(observers[i]));
    }
    bs.rehire();
  }
}
开发者ID:IYABAO,项目名称:folly,代码行数:15,代码来源:RxBenchmark.cpp

示例6: notifyInlineObservers

void notifyInlineObservers(uint iters, int N) {
  for (uint iter = 0; iter < iters; iter++) {
    BenchmarkSuspender bs;
    Subject<int> subject;
    std::vector<Observer<int>*> observers;
    for (int i = 0; i < N; i++) {
      observers.push_back(makeObserver().release());
    }
    for (int i = 0; i < N; i++) {
      subject.observe(observers[i]);
    }
    bs.dismiss();
    subject.onNext(42);
    bs.rehire();
  }
}
开发者ID:IYABAO,项目名称:folly,代码行数:16,代码来源:RxBenchmark.cpp

示例7: addValue

void addValue(unsigned int iters,
              seconds duration, size_t numBuckets,
              size_t callsPerSecond) {
  BenchmarkSuspender suspend;
  BucketedTimeSeries<int64_t> ts(numBuckets, duration);
  suspend.dismiss();

  seconds currentTime(1342000000);
  size_t timeCounter = 0;
  for (unsigned int n = 0; n < iters; ++n, ++timeCounter) {
    if (timeCounter >= callsPerSecond) {
      timeCounter = 0;
      ++currentTime;
    }
    ts.addValue(currentTime, n);
  }
}
开发者ID:HunterChen,项目名称:folly,代码行数:17,代码来源:TimeseriesBenchmark.cpp

示例8: notifySubscribers

void notifySubscribers(uint iters, int N) {
  for (uint iter = 0; iter < iters; iter++) {
    BenchmarkSuspender bs;
    Subject<int> subject;
    std::vector<std::unique_ptr<Observer<int>>> observers;
    std::vector<Subscription<int>> subscriptions;
    subscriptions.reserve(N);
    for (int i = 0; i < N; i++) {
      observers.push_back(makeObserver());
    }
    for (int i = 0; i < N; i++) {
      subscriptions.push_back(subject.subscribe(std::move(observers[i])));
    }
    bs.dismiss();
    subject.onNext(42);
    bs.rehire();
  }
}
开发者ID:IYABAO,项目名称:folly,代码行数:18,代码来源:RxBenchmark.cpp

示例9: subscribeImpl

void subscribeImpl(uint iters, int N, bool countUnsubscribe) {
  for (uint iter = 0; iter < iters; iter++) {
    BenchmarkSuspender bs;
    Subject<int> subject;
    std::vector<std::unique_ptr<Observer<int>>> observers;
    std::vector<Subscription<int>> subscriptions;
    subscriptions.reserve(N);
    for (int i = 0; i < N; i++) {
      observers.push_back(makeObserver());
    }
    bs.dismiss();
    for (int i = 0; i < N; i++) {
      subscriptions.push_back(subject.subscribe(std::move(observers[i])));
    }
    if (countUnsubscribe) {
      subscriptions.clear();
    }
    bs.rehire();
  }
}
开发者ID:IYABAO,项目名称:folly,代码行数:20,代码来源:RxBenchmark.cpp


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