CSet++
Set of defined functions to work with sets
Loading...
Searching...
No Matches
set.cpp File Reference

This is the main benchmark file of the cset library. It contains all the benchmarks needed to test the library's performance. More...

#include <iostream>
#include <string>
#include <vector>
#include <chrono>
#include <thread>
#include <functional>
#include <mutex>
#include "set.h"
+ Include dependency graph for set.cpp:

Go to the source code of this file.

Functions

void print (std::string msg)
 Manages the std::cout resource between simultaneously running threads.
 
void benchmark (std::string name, std::function< void()> function, int n)
 Manages the benchmarking of a passed function.
 
int main ()
 Main entry point that runs a benchmark for every library method.
 

Variables

std::mutex out
 The std::mutex object that locks the std::cout resource.
 

Detailed Description

This is the main benchmark file of the cset library. It contains all the benchmarks needed to test the library's performance.

This file contains some functions that run benchmarks on different threads.
Each function gets executed a thousand times and then the execution time gets printed to the console.

Definition in file set.cpp.

Function Documentation

◆ benchmark()

void benchmark ( std::string  name,
std::function< void()>  function,
int  n 
)

Manages the benchmarking of a passed function.

Parameters
nameThe name of the benchmark to print to the console.
functionThe function object to benchmark.
nThe number of times to run the function.

Definition at line 43 of file set.cpp.

References print().

◆ main()

int main ( )

Main entry point that runs a benchmark for every library method.

Returns
(int) Returns 0 to ensure that all the benchmarks where executed flawlessly.

Definition at line 63 of file set.cpp.

References benchmark(), set::contains(), set::count(), set::diff(), set::intersection(), set::reverse(), set::rsort(), set::sdiff(), set::sort(), set::sunion(), and set::unique().

◆ print()

void print ( std::string  msg)

Manages the std::cout resource between simultaneously running threads.

Parameters
msgThe string to print to the console.

Definition at line 23 of file set.cpp.

References out.

Variable Documentation

◆ out

std::mutex out

The std::mutex object that locks the std::cout resource.

Definition at line 18 of file set.cpp.