Skip to content

Instantly share code, notes, and snippets.

/// @example reflexpr/enum_to_string.cpp
///
/// Copyright Matus Chochlik.
/// Distributed under the Boost Software License, Version 1.0.
/// See accompanying file LICENSE_1_0.txt or copy at
/// http://www.boost.org/LICENSE_1_0.txt
///
#include <experimental/reflect>
#include <iostream>
#include <string_view>
// Compile me! Using:
// g++ benchmark.cpp -std=c++11 -lbenchmark -lpthread -O2 -o benchmark
#include <benchmark/benchmark.h>
#include <boost/dynamic_bitset.hpp>
template <typename Bitset> Bitset GenerateBitset(size_t size) {
Bitset bs(size);
for (size_t i = 0; i < size; ++i)
bs.set(i, (rand() % 2) == 0);
return bs;
2018-09-02 01:41:11
Running ./benchmark
Run on (2 X 1400 MHz CPU s)
CPU Caches:
L1 Data 32K (x2)
L1 Instruction 32K (x2)
L2 Unified 1024K (x1)
***WARNING*** CPU scaling is enabled, the benchmark real time measurements may be noisy and will incur extra overhead.
-----------------------------------------------------------------------------------------------------------------
Benchmark Time CPU Iterations
@Izaron
Izaron / bench_old
Last active September 1, 2018 22:37
2018-09-02 01:36:23
Running ./benchmark
Run on (2 X 1400 MHz CPU s)
CPU Caches:
L1 Data 32K (x2)
L1 Instruction 32K (x2)
L2 Unified 1024K (x1)
***WARNING*** CPU scaling is enabled, the benchmark real time measurements may be noisy and will incur extra overhead.
-----------------------------------------------------------------------------------------------------------------
Benchmark Time CPU Iterations
WORKING WITH bit_count
THE TYPE IS unsigned char
Check correctness...
The fast realization is correct!
Measuring time...
Naive solution runned 0.353572 seconds
Fast solution runned 0.0445373 seconds
The fast solution relative speed: 12.5964%
Compiler: GNU C++ version 6.3.0 20170516
Std lib : GNU libstdc++ version 20170516
Boost v.: 1.68.0
Timings for dynamic_bitset<unsigned char> [3000000 iterations]
--------------------------------------------------
Elapsed: 18.9194
(total count: 31722432)
Compiler: GNU C++ version 6.3.0 20170516
Std lib : GNU libstdc++ version 20170516
Boost v.: 1.68.0
Timings for dynamic_bitset<unsigned char> [3000000 iterations]
--------------------------------------------------
Elapsed: 19.5219
(total count: 31722432)
@Izaron
Izaron / test.cpp
Created August 22, 2018 18:57
Measure the running time with `time ./test` on Linux
#include <iostream>
#include <boost/dynamic_bitset.hpp>
int maxn = 1e8;
int bits = 100;
void test1() {
boost::dynamic_bitset<> bs(bits, abs(rand()));
int a = 0;
for (int i = 0; i < maxn; i++) {
#include <bits/stdc++.h>
using namespace std;
vector<string> crop(string& s) {
vector<string> vec;
string cur = "";
for (int i = 0; i < (int) s.size(); i++) {
if (s[i] < 'a' || s[i] > 'z') {
// if s[i] is not a lowercase english letter
@Izaron
Izaron / cppan.yml
Last active December 28, 2016 12:54
local_settings:
build_shared_libs: true
silent: false
build:
generator: Visual Studio 12 2013
toolset: v120_xp