All Projects → mikewei → gtestx

mikewei / gtestx

Licence: other
A C++ benchmark extension for gtest

Programming Languages

C++
36643 projects - #6 most used programming language
python
139335 projects - #7 most used programming language
Makefile
30231 projects

Projects that are alternatives of or similar to gtestx

snowman
Welcome to Snowman App – a Data Matching Benchmark Platform.
Stars: ✭ 25 (+31.58%)
Mutual labels:  benchmark
touchstone
Smart benchmarking of pull requests with statistical confidence
Stars: ✭ 33 (+73.68%)
Mutual labels:  benchmark
sbt-jmh
"Trust no one, bench everything." - sbt plugin for JMH (Java Microbenchmark Harness)
Stars: ✭ 740 (+3794.74%)
Mutual labels:  benchmark
LFattNet
Attention-based View Selection Networks for Light-field Disparity Estimation
Stars: ✭ 41 (+115.79%)
Mutual labels:  benchmark
NPB-CPP
NAS Parallel Benchmark Kernels in C/C++. The parallel versions are in FastFlow, TBB, and OpenMP.
Stars: ✭ 18 (-5.26%)
Mutual labels:  benchmark
scATAC-benchmarking
Benchmarking computational single cell ATAC-seq methods
Stars: ✭ 137 (+621.05%)
Mutual labels:  benchmark
ronin
RoNIN: Robust Neural Inertial Navigation in the Wild
Stars: ✭ 144 (+657.89%)
Mutual labels:  benchmark
Hetero-Mark
A Benchmark Suite for Heterogeneous System Computation
Stars: ✭ 41 (+115.79%)
Mutual labels:  benchmark
criterion
statistics-driven micro-benchmarking framework
Stars: ✭ 17 (-10.53%)
Mutual labels:  benchmark
perf
Linux Perf subsystem bindings for Go
Stars: ✭ 19 (+0%)
Mutual labels:  benchmark
CBLUE
中文医疗信息处理基准CBLUE: A Chinese Biomedical Language Understanding Evaluation Benchmark
Stars: ✭ 379 (+1894.74%)
Mutual labels:  benchmark
Java-Logging-Framework-Benchmark
Suite for benchmarking Java logging frameworks.
Stars: ✭ 16 (-15.79%)
Mutual labels:  benchmark
eCommerceSearchBench
E-commerce search benchmark is the first end-to-end application benchmark for e-commerce search system with personalized recommendations.This work is joint with Prof. Jianfeng Zhan (http://www.benchcouncil.org/zjf.html) 's team, who is also the chair of International Open Benchmark Council (BenchCouncil, http://www.benchcouncil.org/).
Stars: ✭ 29 (+52.63%)
Mutual labels:  benchmark
link-too-big
Link Too Big? Make Link Short
Stars: ✭ 12 (-36.84%)
Mutual labels:  benchmark
Language-Arena
C++ vs D vs Go benchmark
Stars: ✭ 19 (+0%)
Mutual labels:  benchmark
benchmark-kit
phpbenchmarks.com kit to add your benchmark.
Stars: ✭ 31 (+63.16%)
Mutual labels:  benchmark
benchdiff
No description or website provided.
Stars: ✭ 41 (+115.79%)
Mutual labels:  benchmark
yjit-bench
Set of benchmarks for the YJIT CRuby JIT compiler
Stars: ✭ 38 (+100%)
Mutual labels:  benchmark
bench
⏱️ Reliable performance measurement for Go programs. All in one design.
Stars: ✭ 33 (+73.68%)
Mutual labels:  benchmark
Edge-Detection-project
Tiny Image in Javascript - Edge Detection Algorithms
Stars: ✭ 27 (+42.11%)
Mutual labels:  benchmark

GTESTX - A C++ benchmark extension for gtest

Benchmark or performance-testing is often as important as unit test in many environment such as server side development. GTESTX is just a convenient and simple C++ benchmark tool. It is based on gtest framework, so if you are familiar with gtest you can write benchmark code easily only by knowing some extended macros.

Examples

PERF_TEST (similar with TEST macro) is a simplest gtestx macro. By default the function body will be called in a dead loop for a period of time and then the performance counter recorded is reported.

This is an example:

#include <sys/types.h>
#include <unistd.h>
#include "gtestx/gtestx.h"

TEST(SimpleTest, SysCall)
{
  ASSERT_NE(0, getppid());
}

// Just like TEST macro, use PERF_TEST for performance testing
PERF_TEST(SimpleTest, SysCallPerf)
{
  getppid();
}

We can run it as normal gtest tests:

$ ./gtestx_examples --gtest_filter='SimpleTest*'
[==========] Running 2 tests from 1 test case.
[----------] Global test environment set-up.
[----------] 2 tests from SimpleTest
[ RUN      ] SimpleTest.SysCall
[       OK ] SimpleTest.SysCall (0 ms)
[ RUN      ] SimpleTest.SysCallPerf
      count: 25,369,636
       time: 1.508939 s
         HZ: 16,812,897.009090
       1/HZ: 0.000000059 s
[       OK ] SimpleTest.SysCallPerf (1509 ms)
[----------] 2 tests from SimpleTest (1509 ms total)

[----------] Global test environment tear-down
[==========] 2 tests from 1 test case ran. (1510 ms total)
[  PASSED  ] 2 tests.

Another example:

class StdMapTest : public testing::Test
{
protected:
  virtual ~StdMapTest() {}
  virtual void SetUp() override {
    for (int i = 0; i < 1000; i++) {
      map_.emplace(i, 1);
    }
  }
  virtual void TearDown() override {}

  std::map<int,int> map_;
};

PERF_TEST_F(StdMapTest, FindPerf)
{
  map_.find(999);
}

Macros

Almost all gtest macro has a GTESTX version:

  • PERF_TEST
  • PERF_TEST_F
  • PERF_TEST_P
  • TYPED_PERF_TEST
  • TYPED_PERF_TEST_P

And there are some more macros which can be used with additional options:

  • PERF_TEST_OPT
  • PERF_TEST_F_OPT
  • PERF_TEST_P_OPT
  • TYPED_PERF_TEST_OPT
  • TYPED_PERF_TEST_P_OPT

You can learn how to use them by read example code in examples directory.

Dependencies

  • gtest (>= 1.7 is well tested)
  • gflags (>= 2.0 is well tested)

Compile

Actually all gtestx code (without tests and examples) are only two files - gtestx.h and gtestx.cc, so you can import them into your projects easily.

Compile using Bazel

A Bazel BUILD file is also available, you can use it to build tests and examples or linked it to other bazel project. Note that this bazel BUILD depends on gtest and gflags modules which are modified-for-bazel version on my github.

For example you can build examples as follows:

mkdir work
cd work
touch WORKSPACE
git clone https://github.com/mikewei/gtestx.git
git clone https://github.com/mikewei/third_party.git
bazel build gtestx:examples

Compile using make

You can also build tests and examples using Makefile:

git clone https://github.com/mikewei/gtestx.git
cd examples
# change some directory setting in Makefile
make

Run

Run GTESTX benchmark tests just as normal gtest tests. e.g.

./gtestx_examples --gtest_filters='SimpleTest.*'

Or run within bazel:

bazel run gtestx:examples -- --gtest_filter='SimpleTest.*'

Also GTESTX supply two more command line options:

-hz CALLS_PER_SECOND
-time RUNNING_MILLISECONDS

For example if you want run SimpleTest with 10000 times/sec for 10 seconds, use commonds bellow:

./gtestx_examples --gtest_filters='SimpleTest.*' -hz=10000 -time=10000

Tutorial (Chinese)

这里有一篇介绍如何使用gtestx的文章

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].