OpenVPN 3 Core Library
Loading...
Searching...
No Matches
test_cpu_time.cpp File Reference
#include "test_common.hpp"
#include <cstdint>
#include <unistd.h>
#include <memory>
#include <mutex>
#include <openvpn/time/cputime.hpp>
#include <algorithm>
Include dependency graph for test_cpu_time.cpp:

Go to the source code of this file.

Namespaces

namespace  unittests
 

Macros

#define DEBUG_DUMP(msg, st, en, rt, chst, chen, chrt, md)
 
#define MEASURE(v, chkv, thread)
 
#define CALCULATE(msg, st, en, rt, chst, chen, chrt, md)
 

Typedefs

typedef std::shared_ptr< std::thread > ThreadPtr
 

Functions

void update_thread_runtime (double val)
 
static void unittests::workload (const uint16_t multiplier)
 
 unittests::TEST (CPUTime, cpu_time_pid)
 
void unittests::worker_thread (const uint8_t id)
 
void unittests::run_threads (const uint8_t num_threads)
 
 unittests::TEST (CPUTime, cpu_time_thread_1)
 
 unittests::TEST (CPUTime, cpu_time_thread_numcores)
 

Variables

std::mutex update_guard
 
double thread_runtime = 0
 

Macro Definition Documentation

◆ CALCULATE

#define CALCULATE (   msg,
  st,
  en,
  rt,
  chst,
  chen,
  chrt,
  md 
)
Value:
double rt = en - st; \
double chrt = chen - chst; \
double md = std::max(rt, chrt) - std::min(rt, chrt); \
DEBUG_DUMP(msg, st, en, rt, chst, chen, chrt, md)
#define msg(flags,...)

Definition at line 64 of file test_cpu_time.cpp.

◆ DEBUG_DUMP

#define DEBUG_DUMP (   msg,
  st,
  en,
  rt,
  chst,
  chen,
  chrt,
  md 
)
Value:
{ \
}

Definition at line 54 of file test_cpu_time.cpp.

◆ MEASURE

#define MEASURE (   v,
  chkv,
  thread 
)
Value:
double v = openvpn::cpu_time(thread); \
ASSERT_GE(v, 0); \
double chkv = static_cast<double>(time(NULL))
double cpu_time(const bool thread=false)
Definition cputime.hpp:76

Definition at line 59 of file test_cpu_time.cpp.

Typedef Documentation

◆ ThreadPtr

typedef std::shared_ptr<std::thread> ThreadPtr

Definition at line 71 of file test_cpu_time.cpp.

Function Documentation

◆ update_thread_runtime()

void update_thread_runtime ( double  val)

Definition at line 80 of file test_cpu_time.cpp.

Here is the caller graph for this function:

Variable Documentation

◆ thread_runtime

double thread_runtime = 0

Definition at line 78 of file test_cpu_time.cpp.

◆ update_guard

std::mutex update_guard

Definition at line 77 of file test_cpu_time.cpp.