From 7b5de5ab7dad0a9d6627e63c8757c9c4f0c6b1b3 Mon Sep 17 00:00:00 2001 From: Borislav Stanimirov Date: Wed, 6 Mar 2024 21:13:20 +0200 Subject: [PATCH] doc, copyright years --- LICENSE.txt | 2 +- README.md | 43 +++++++++++++++------------------ include/picobench/picobench.hpp | 8 ++++-- 3 files changed, 27 insertions(+), 26 deletions(-) diff --git a/LICENSE.txt b/LICENSE.txt index 708a9b9..5ef5fa6 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,4 +1,4 @@ -Copyright (c) 2017-2023 Borislav Stanimirov +Copyright (c) 2017-2024 Borislav Stanimirov Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index 9ca3b61..3ab48a4 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,4 @@ + # picobench [![Language](https://img.shields.io/badge/language-C++-blue.svg)](https://isocpp.org/) [![Standard](https://img.shields.io/badge/C%2B%2B-11-blue.svg)](https://en.wikipedia.org/wiki/C%2B%2B#Standardization) [![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://opensource.org/licenses/MIT) @@ -45,20 +46,18 @@ PICOBENCH(rand_vector_reserve); The output of this benchmark might look like this: ``` -=============================================================================== - Name (* = baseline) | Dim | Total ms | ns/op |Baseline| Ops/second -=============================================================================== - rand_vector * | 8 | 0.001 | 167 | - | 5974607.9 - rand_vector_reserve | 8 | 0.000 | 55 | 0.329 | 18181818.1 - rand_vector * | 64 | 0.004 | 69 | - | 14343343.8 - rand_vector_reserve | 64 | 0.002 | 27 | 0.400 | 35854341.7 - rand_vector * | 512 | 0.017 | 33 | - | 30192239.7 - rand_vector_reserve | 512 | 0.012 | 23 | 0.710 | 42496679.9 - rand_vector * | 4096 | 0.181 | 44 | - | 22607850.9 - rand_vector_reserve | 4096 | 0.095 | 23 | 0.527 | 42891848.9 - rand_vector * | 8196 | 0.266 | 32 | - | 30868196.3 - rand_vector_reserve | 8196 | 0.207 | 25 | 0.778 | 39668749.5 -=============================================================================== + Name (* = baseline) | Dim | Total ms | ns/op |Baseline| Ops/second +--------------------------|--------:|----------:|--------:|-------:|----------: + rand_vector * | 8 | 0.001 | 167 | - | 5974607.9 + rand_vector_reserve | 8 | 0.000 | 55 | 0.329 | 18181818.1 + rand_vector * | 64 | 0.004 | 69 | - | 14343343.8 + rand_vector_reserve | 64 | 0.002 | 27 | 0.400 | 35854341.7 + rand_vector * | 512 | 0.017 | 33 | - | 30192239.7 + rand_vector_reserve | 512 | 0.012 | 23 | 0.710 | 42496679.9 + rand_vector * | 4096 | 0.181 | 44 | - | 22607850.9 + rand_vector_reserve | 4096 | 0.095 | 23 | 0.527 | 42891848.9 + rand_vector * | 8196 | 0.266 | 32 | - | 30868196.3 + rand_vector_reserve | 8196 | 0.207 | 25 | 0.778 | 39668749.5 ``` ...which tells us that we see a noticeable performance gain when we use `reserve` but the effect gets less prominent for bigger numbers of elements inserted. @@ -142,12 +141,10 @@ Instead of `std::cout` you may want to use another `std::ostream` instance of yo As mentioned above `report.to_text_concise(ostream)` outputs a report without the iterations breakdown. With the first example of benchmarking adding elements to a `std::vector`, the output would be this: ``` -=============================================================================== - Name (* = baseline) | ns/op | Baseline | Ops/second -=============================================================================== - rand_vector * | 36 | - | 27427782.7 - rand_vector_reserve | 24 | 0.667 | 40754573.7 -=============================================================================== + Name (* = baseline) | ns/op | Baseline | Ops/second +--------------------------|--------:|---------:|-----------: + rand_vector * | 36 | - | 27427782.7 + rand_vector_reserve | 24 | 0.667 | 40754573.7 ``` Note that in this case the information that the effect of using `reserve` gets less prominent with more elements is lost. @@ -178,9 +175,9 @@ You can set a result for a benchmark using `state::set_result`. Here is an examp void my_benchmark(picobench::state& s) { int sum = 0; - for (auto i : s) + for (int i : s) { - sum += myfunc(*i); + sum += myfunc(i); } s.set_result(sum); } @@ -286,4 +283,4 @@ This software is distributed under the MIT Software License. See accompanying file LICENSE.txt or copy [here](https://opensource.org/licenses/MIT). -Copyright © 2017-2023 [Borislav Stanimirov](http://github.com/iboB) +Copyright © 2017-2024 [Borislav Stanimirov](http://github.com/iboB) diff --git a/include/picobench/picobench.hpp b/include/picobench/picobench.hpp index 72eca12..4eea062 100644 --- a/include/picobench/picobench.hpp +++ b/include/picobench/picobench.hpp @@ -1,4 +1,4 @@ -// picobench v2.05 +// picobench v2.07 // https://github.com/iboB/picobench // // A micro microbenchmarking library in a single header file @@ -7,7 +7,7 @@ // // MIT License // -// Copyright(c) 2017-2023 Borislav Stanimirov +// Copyright(c) 2017-2024 Borislav Stanimirov // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files(the "Software"), to deal @@ -30,6 +30,10 @@ // // VERSION HISTORY // +// 2.07 (2024-03-06) * Text output is now markdown compatible +// * Allow including picobench.hpp before defining +// PICOBENCH_IMPLEMENT +// 2.06 (2023-11-24) Intenal. This file was not affected // 2.05 (2023-04-26) Fixed MinGW build // 2.04 (2023-04-12) Added CLI args to run specific benchmarks or suites // 2.03 (2023-03-21) * Added PICOBENCH_UNIQUE_SYM_SUFFIX