• Stars
    star
    124
  • Rank 278,214 (Top 6 %)
  • Language
    C++
  • License
    zlib License
  • Created over 7 years ago
  • Updated 22 days ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A simple C++ 03/11/etc timer class for ~microsecond-precision cross-platform benchmarking. The implementation is as limited and as simple as possible to create the lowest amount of overhead.

plf::nanotimer

A simple C++ 03/11/etc timer class for ~microsecond-precision cross-platform benchmarking. The implementation is as limited and simple as possible to afford the lowest amount of overhead.

Use as follows:

plf::nanotimer timer;


timer.start()

// Do something here

double results = timer.get_elapsed_ns();
std::cout << "Timing: " << results << " nanoseconds." << std::endl;


timer.start(); // "start" has the same semantics as "restart".

// Do something else

results = timer.get_elapsed_ms();
std::cout << "Timing: " << results << " milliseconds." << std::endl;


timer.start()

plf::microsecond_delay(15); // Delay program for 15 microseconds

results = timer.get_elapsed_us();
std::cout << "Timing: " << results << " microseconds." << std::endl;

Timer member functions:

void start(): start or restart timer

double get_elapsed_ns(): get elapsed time in nanoseconds

double get_elapsed_us(): get elapsed time in microseconds

double get_elapsed_ms(): get elapsed time in milliseconds

Non-member functions:

void plf::millisecond_delay(double x): delay the program until x milliseconds have passed

void plf::microsecond_delay(double x): delay the program until x microseconds have passed

void plf::nanosecond_delay(double x): delay the program until x nanoseconds have passed

Timer 'pausing':

I determined that a 'pause'-style function would add too much complexity to the class for simple benchmarking, which in turn might interfere with performance analysis, so if you need a 'pause' function do something like this:

plf::nanotimer timer;


timer.start()
// Do something here
double results = timer.get_elapsed_ns();

// Do something else - timer 'paused'

timer.start()

// Do stuff

results += timer.get_elapsed_ns();

std::cout << "Timing: " << results << " nanoseconds." << std::endl;

More Repositories

1

plf_colony

An unordered C++ data container providing fast iteration/insertion/erasure while maintaining pointer/iterator validity to non-erased elements regardless of insertions/erasures. Provides higher-performance than std:: library containers for high-modification scenarios with unordered data.
C++
382
star
2

plf_list

A drop-in replacement for std::list with 293% faster insertion, 57% faster erasure, 17% faster iteration and 77% faster sorting on average. 20-24% speed increase in use-case testing.
C++
141
star
3

Windows-10-11-Simplifier

Windows 10/11 Simplifier - A script for automating simplifications and maintenance
Batchfile
118
star
4

plf_hive

plf::hive is a fork of plf::colony to match the current C++ standards proposal.
C++
66
star
5

plf_stack

A C++ data container replicating std::stack functionality but with better performance than standard library containers in a stack context.
C++
60
star
6

plf_queue

A C++ data container replicating std::queue functionality but with better performance.
C++
28
star
7

plf_indiesort

A sort wrapper enabling both use of random-access sorting on non-random access containers, and increased performance for the sorting of large types.
C++
18
star
8

plf_engine

A modern(ish) cross-platform open-source 2D game engine built on top of SDL2. C++98/03/11/14/17 compatible. Requires plf::colony and plf::stack.
C++
15
star
9

plf_rand

A replacement for rand()/srand() that's ~700% faster and typically has better statistical distribution. An adaptationof Melissa O'Neill's PCG rand with a fallback to xor-rand for 32-bit code.
C++
12
star
10

plf_reorderase

A faster method for singular erasures, ranged erasures, and erase_if-style erasures for vector/deque/static_vector when element order is not important.
C++
6
star
11

win10_disable_defender

A simple script to disable the Defender antivirus in Windows 10. This can occasionally be useful, for example when wanting to avoid overhead during benchmarking or for low-latency applications like audio hosts.
Batchfile
4
star
12

plf_colony_old

Deprecated version of colony which will be updated when and if bugs are found. For backwards compatibility with users of colony version 5.
C++
1
star