# HG changeset patch # User Hasan Yavuz Ă–ZDERYA # Date 2017-08-13 06:45:13 # Node ID 8ef18859c787aa22cdfcdea9b66910bc0e351661 # Parent ec2bd041e1deb3698a4c9f2646ffbf5e2c76fcee added timing tests diff --git a/tests/test.cpp b/tests/test.cpp --- a/tests/test.cpp +++ b/tests/test.cpp @@ -17,6 +17,7 @@ along with serialplot. If not, see . */ +#include #define CATCH_CONFIG_MAIN // This tells Catch to provide a main() - only do this in one cpp file #include "catch.hpp" @@ -147,3 +148,25 @@ TEST_CASE("ChunkedBuffer accessing data" REQUIRE(b.sample(CHUNK_SIZE*2-1) == 60); REQUIRE(b.sample(CHUNK_SIZE*3-1) == 70); } + +TEST_CASE("ChunkedBuffer time measurement", "[.][timing][memory]") +{ + const int N = CHUNK_SIZE*10; + clock_t start, end; + double samples[N]; + ChunkedBuffer b; + start = clock(); + b.addSamples(samples, N); + end = clock(); + REQUIRE(b.size() == N); + WARN("addSamples(" << N << ") took: " << ((end-start) / ((double) CLOCKS_PER_SEC))); + + // access + start = clock(); + for (int i =0; i < N; i++) + { + samples[i] = b.sample(i); + } + end = clock(); + WARN("sample()*"<< N <<" took: " << ((end-start) / ((double) CLOCKS_PER_SEC))); +}