Generating flame graph

master
denes 5 years ago
parent 8ee57e83e2
commit 3b26c69377
Signed by: denes
GPG Key ID: A7D50EAD42F9FC9F

3
.gitmodules vendored

@ -1,3 +1,6 @@
[submodule "Catch2"]
path = Catch2
url = https://github.com/catchorg/Catch2.git
[submodule "FlameGraph"]
path = FlameGraph
url = https://github.com/brendangregg/FlameGraph.git

@ -1,7 +1,12 @@
cmake_minimum_required (VERSION 3.10)
project (PerformanceMeasuring)
set(HEADER_FILES dummy_lib.hpp Catch2/single_include/catch2/catch.hpp)
set(CMAKE_CXX_FLAGS "-ggdb")
add_executable(performance_measuring catch2_test1.cpp ${HEADER_FILES})
target_include_directories(performance_measuring PRIVATE . Catch2/single_include)
set(CATCH_HEADER_FILES dummy_lib.hpp Catch2/single_include/catch2/catch.hpp)
add_executable(performance_measuring_test catch2_test1.cpp ${HEADER_FILES})
target_include_directories(performance_measuring_test PRIVATE . Catch2/single_include)
set(HEADER_FILES dummy_lib.hpp)
add_executable(performance_measuring main.cpp ${HEADER_FILES})
target_include_directories(performance_measuring PRIVATE .)

@ -0,0 +1 @@
Subproject commit 1b1c6deede9c33c5134c920bdb7a44cc5528e9a7

12
Jenkinsfile vendored

@ -15,11 +15,19 @@ pipeline {
}
}
stage('Run') {
stage('Running catch2 tests') {
steps {
sh 'performance_measuring'
sh 'performance_measuring_test'
}
}
stage('Generatin flamegraph') {
steps {
sh 'generate_flame_graph.sh'
archiveArtifacts artifacts: 'flamegraph.svg', fingerprint: true
}
}
}
}

@ -16,6 +16,8 @@ std::vector<int> generate_random_numbers(int n, int min, int max)
return v;
}
// How many times the smallest element occurts in a vector?
TEST_CASE( "Simple test" ) {
std::vector<int> v = { 1, 2, 3, 1};
REQUIRE( performance_measuring::count_on_the_way(v) == 2 );

@ -4,6 +4,8 @@
#include <vector>
#include <algorithm>
// How many times the smallest element occurts in a vector?
namespace performance_measuring {
int count_on_the_way(const std::vector<int>& v)

@ -0,0 +1,35 @@
#include <cstdlib>
#include <ctime>
#include <cassert>
#include <vector>
#include "dummy_lib.hpp"
std::vector<int> generate_random_numbers(int n, int min, int max)
{
std::srand(std::time(nullptr));
std::vector<int> v(n);
for (int i = 0; i < n; ++i)
v[i] = min + std::rand() / ((RAND_MAX + 1u)/max);
return v;
}
int main(int /*argc*/, char* /*argv*/[])
{
std::vector<int> v = generate_random_numbers(10000, 0, 1000);
// How many times does the smallest element occursts in the vector?
int r1 = performance_measuring::count_on_the_way(v);
int r2 = performance_measuring::min_element_and_count(v);
int r3 = performance_measuring::sort_and_upper_bound(v);
assert(r1 == r2);
assert(r2 == r3);
return EXIT_SUCCESS;
}
Loading…
Cancel
Save