Skip to content

Commit 4d96b25

Browse files
DigitalInBluec72578jiverson002
authored
Develop (#150)
* Use _WIN32 instead of WIN32 preprocessor macro (#138) - _WIN32 is the recommended preprocessor macro - Substitute occurrences of WIN32 with _WIN32 using: git grep -lw -e 'WIN32' -- | xargs sed -i -e 's/\<WIN32\>/_WIN32/g' * Cleanup some compiler issues on MacOS. (#141) In file include/celero/ThreadLocal.h: * `thread_local` is a C++ keyword so using an #ifdef check for its existence is not reliable. Instead, check for C++11 support to determine if `thread_local` is already defined. See here https://stackoverflow.com/questions/5047971/how-do-i-check-for-c11-support. * Also the check `#if __STDC_VERSION__ >= 201112` is not meaningful, since presumably Celero is being compiled with a C++ compiler, so it has been removed. In file src/Memory.cpp: * Added include for `<cstring>` so that `strlen` and `strncmp` are defined for Apple environment. Fixes #140 * Made it easier to use the Fixed baseline properly with UDMs. * Improving the "cost of pimpl" experiment. * #148 Added UDM to the output file Also remove Google Test submodule. * Create codeql-analysis.yml (#149) * Removed requirement for GTest in Travis.ci * #143 Added clarification to README.md on Doxygen. * Code Cleanup * Copyright Update 2021 Co-authored-by: Wolfgang Stöggl <c72578@yahoo.de> Co-authored-by: jiverson002 <jiverson002@users.noreply.github.com>
1 parent 0d7b24d commit 4d96b25

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+382
-240
lines changed

.github/workflows/codeql-analysis.yml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# For most projects, this workflow file will not need changing; you simply need
2+
# to commit it to your repository.
3+
#
4+
# You may wish to alter this file to override the set of languages analyzed,
5+
# or to provide custom queries or build logic.
6+
#
7+
# ******** NOTE ********
8+
# We have attempted to detect the languages in your repository. Please check
9+
# the `language` matrix defined below to confirm you have the correct set of
10+
# supported CodeQL languages.
11+
#
12+
name: "CodeQL"
13+
14+
on:
15+
push:
16+
branches: [ master, develop ]
17+
pull_request:
18+
# The branches below must be a subset of the branches above
19+
branches: [ master ]
20+
schedule:
21+
- cron: '31 20 * * 6'
22+
23+
jobs:
24+
analyze:
25+
name: Analyze
26+
runs-on: ubuntu-latest
27+
28+
strategy:
29+
fail-fast: false
30+
matrix:
31+
language: [ 'cpp' ]
32+
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
33+
# Learn more:
34+
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed
35+
36+
steps:
37+
- name: Checkout repository
38+
uses: actions/checkout@v2
39+
40+
# Initializes the CodeQL tools for scanning.
41+
- name: Initialize CodeQL
42+
uses: github/codeql-action/init@v1
43+
with:
44+
languages: ${{ matrix.language }}
45+
# If you wish to specify custom queries, you can do so here or in a config file.
46+
# By default, queries listed here will override any specified in a config file.
47+
# Prefix the list here with "+" to use these queries and those in the config file.
48+
# queries: ./path/to/local/query, your-org/your-repo/queries@main
49+
50+
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
51+
# If this step fails, then you should remove it and run the build manually (see below)
52+
- name: Autobuild
53+
uses: github/codeql-action/autobuild@v1
54+
55+
# ℹ️ Command-line programs to run using the OS shell.
56+
# 📚 https://git.io/JvXDl
57+
58+
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
59+
# and modify them (or add more) to build your code if your project
60+
# uses a compiled language
61+
62+
#- run: |
63+
# make bootstrap
64+
# make release
65+
66+
- name: Perform CodeQL Analysis
67+
uses: github/codeql-action/analyze@v1

.gitmodules

Lines changed: 0 additions & 3 deletions
This file was deleted.

.travis.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,43 +52,43 @@ matrix:
5252

5353
# Clang 3.9
5454
- os: linux
55-
env: LLVM_VERSION=3.9.0 CMAKE_OPTIONS="-DCELERO_ENABLE_TESTS=1"
55+
env: LLVM_VERSION=3.9.0 CMAKE_OPTIONS=""
5656
compiler: clang
5757

5858
# Clang 5.0.1
5959
- os: linux
60-
env: LLVM_VERSION=5.0.1 CMAKE_OPTIONS="-DCELERO_ENABLE_TESTS=1"
60+
env: LLVM_VERSION=5.0.1 CMAKE_OPTIONS=""
6161
compiler: clang
6262

6363
# Clang 7.0.0
6464
- os: linux
65-
env: LLVM_VERSION=7.0.0 CMAKE_OPTIONS="-DCELERO_ENABLE_TESTS=1"
65+
env: LLVM_VERSION=7.0.0 CMAKE_OPTIONS=""
6666
compiler: clang
6767

6868
# Clang 8.0.0
6969
- os: linux
70-
env: LLVM_VERSION=7.0.0 CMAKE_OPTIONS="-DCELERO_ENABLE_TESTS=1"
70+
env: LLVM_VERSION=7.0.0 CMAKE_OPTIONS=""
7171
compiler: clang
7272

7373
# GCC 6
7474
- os: linux
75-
env: COMPILER=g++-6 CMAKE_OPTIONS="-DCELERO_ENABLE_TESTS=1"
75+
env: COMPILER=g++-6 CMAKE_OPTIONS=""
7676
compiler: gcc
7777

7878
# GCC 7
7979
- os: linux
80-
env: COMPILER=g++-7 CMAKE_OPTIONS="-DCELERO_ENABLE_TESTS=1"
80+
env: COMPILER=g++-7 CMAKE_OPTIONS=""
8181
compiler: gcc
8282

8383
# GCC 8
8484
- os: linux
85-
env: COMPILER=g++-8 CMAKE_OPTIONS="-DCELERO_ENABLE_TESTS=1"
85+
env: COMPILER=g++-8 CMAKE_OPTIONS=""
8686
compiler: gcc
8787

8888
# GCC 8
8989
- os: linux
9090
name: Complete Build
91-
env: COMPILER=g++-8 CMAKE_OPTIONS="-DCELERO_ENABLE_TESTS=1 -DCELERO_ENABLE_EXPERIMENTS=1"
91+
env: COMPILER=g++-8 CMAKE_OPTIONS="-DCELERO_ENABLE_EXPERIMENTS=1"
9292
compiler: gcc
9393

9494
##########################################################################
@@ -97,7 +97,7 @@ matrix:
9797
# With debug mode
9898
- os: linux
9999
name: Debug Build
100-
env: LLVM_VERSION=default CMAKE_OPTIONS="-DCELERO_ENABLE_TESTS=1 -DCMAKE_BUILD_TYPE=DEBUG"
100+
env: LLVM_VERSION=default CMAKE_OPTIONS="-DCMAKE_BUILD_TYPE=DEBUG"
101101
compiler: clang
102102

103103
# Temporarily broken within Travis.CI for CMake's update

CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,9 +227,8 @@ add_subdirectory(experiments)
227227

228228
if(CELERO_ENABLE_TESTS)
229229
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
230-
add_subdirectory(googletest)
231230
add_subdirectory(test)
232-
endif()
231+
endif()
233232

234233

235234
# ------------------------------------------------------------------------------

README.md

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
### C++ Benchmarking Library
44

5-
Copyright 2017-2019 John Farrier
5+
Copyright 2017-2021 John Farrier
66

77
Apache 2.0 License
88

@@ -38,6 +38,8 @@ Celero has been successfully built on the following platforms during development
3838
- XCode v10.3
3939
- XCode v11.0
4040

41+
As of v2.7, Celero requres the developer to provide GoogleTest in order to build unit tests. We suggest using a package manager such as VCPKG or Conan to provide the latest version of the library.
42+
4143
#### Quality Control
4244

4345
| Tooling | Status |
@@ -166,7 +168,7 @@ Here is an example of a simple Celero Benchmark. (Note: This is a complete, runn
166168

167169
#include <random>
168170

169-
#ifndef WIN32
171+
#ifndef _WIN32
170172
#include <cmath>
171173
#include <cstdlib>
172174
#endif
@@ -306,7 +308,7 @@ Celero can automatically run threaded benchmarks. `BASELINE_T` and `BENCHMARK_T
306308
307309
```cpp
308310
BASELINE_T(groupName, baselineName, fixtureName, samples, iterations, threads);
309-
BASELINE_FIXED_T(groupName, baselineName, fixtureName, samples, iterations, threads, useconds);
311+
BASELINE_FIXED_T(groupName, baselineName, fixtureName, iterations, threads, useconds);
310312
311313
BENCHMARK_T(groupName, benchmarkName, fixtureName, samples, iterations, threads);
312314
BENCHMARK_TEST_T(groupName, benchmarkName, fixtureName, samples, iterations, threads, target);
@@ -318,22 +320,24 @@ While Celero typically measures the baseline time and then executes benchmark ca
318320

319321
```cpp
320322
// No threads or test fixtures.
321-
BASELINE_FIXED(groupName, baselineName, samples, iterations, useconds);
323+
BASELINE_FIXED(groupName, baselineName, iterations, useconds);
322324

323325
// For using test fixtures:
324-
BASELINE_FIXED_F(groupName, baselineName, fixtureName, samples, iterations, useconds);
326+
BASELINE_FIXED_F(groupName, baselineName, fixtureName, iterations, useconds);
325327

326328
// For using threads and test fixtures.
327-
BASELINE_FIXED_T(groupName, baselineName, fixtureName, samples, iterations, threads, useconds);
329+
BASELINE_FIXED_T(groupName, baselineName, fixtureName, iterations, threads, useconds);
328330
```
329331
330332
Example:
331333
332334
```cpp
333-
BASELINE_FIXED_F(DemoTransform, FixedTime, DemoTransformFixture, 30, 10000, 100)
335+
BASELINE_FIXED_F(DemoTransform, FixedTime, DemoTransformFixture, 1, 100)
334336
{ /* Nothing to do */ }
335337
```
336338

339+
It is important that if your measurements use a test fixture, that your baseline (even if fixed) should use a test fixture as well. Features such as User-Defined Measurements (UDMs) look to the baseline class to detect if other features are present. If the baseline does not use a test fixuture, Celero will not know that other classes do use a test fixture that offers a UDM.
340+
337341
### User-Defined Measurements (UDM)
338342

339343
Celero, by default, measures the execution time of your experiments. If you want to measure anything else, say for example the number of page faults via [PAPI](http://icl.cs.utk.edu/projects/papi/wiki/PAPIC:Overview), *user-defined measurements* are for you.
@@ -461,7 +465,7 @@ sudo cpupower frequency-set --governor powersave
461465

462466
- Benchmarks should always be performed on Release builds. Never measure the performance of a Debug build and make changes based on the results. The (optimizing) compiler is your friend concerning code performance.
463467
- Accuracy is tied very closely to the total number of samples and the sample sizes. As a general rule, you should aim to execute your baseline code for about as long as your longest benchmark test. Further, it is helpful if all of the benchmark tests take about the same order of magnitude of execution time. (Don't compare a baseline that executed in 0.1 seconds with benchmarks that take 60 seconds and an hour, respectively.)
464-
- Celero has Doxygen documentation of its API.
468+
- Celero has Doxygen-style documentation of its API. (The Doxyfile is provided. The user must generate the documentation.)
465469
- Celero supports test fixtures for each baseline group.
466470

467471
## Celero Charts

experiments/DemoSimple/DemoSimple.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
#include <random>
44

5-
#ifndef WIN32
5+
#ifndef _WIN32
66
#include <cmath>
77
#include <cstdlib>
88
#endif

experiments/DemoSimpleJUnit/DemoSimpleJUnit.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include <celero/Celero.h>
22

3-
#ifndef WIN32
3+
#ifndef _WIN32
44
#include <cmath>
55
#include <cstdlib>
66
#endif

experiments/DemoTransform/DemoTransform.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#include <algorithm>
55
#include <functional>
66

7-
#ifndef WIN32
7+
#ifndef _WIN32
88
#include <cmath>
99
#include <cstdlib>
1010
#endif
@@ -101,8 +101,8 @@ BASELINE_F(DemoTransform, ForLoop, DemoTransformFixture, 30, 10000)
101101
}
102102
}
103103

104-
// BASELINE_FIXED_F(DemoTransform, FixedTime, DemoTransformFixture, 30, 10000, 100)
105-
// { }
104+
BASELINE_FIXED_F(DemoTransform, FixedTime, DemoTransformFixture, 1, 100)
105+
{ }
106106

107107
BENCHMARK_F(DemoTransform, StdTransform, DemoTransformFixture, 30, 10000)
108108
{

0 commit comments

Comments
 (0)