Changeset - 8ef18859c787
[Not reviewed]
longmem
0 1 0
Hasan Yavuz Ă–ZDERYA - 8 years ago 2017-08-13 06:45:13
hy@ozderya.net
added timing tests
1 file changed with 23 insertions and 0 deletions:
0 comments (0 inline, 0 general)
tests/test.cpp
Show inline comments
 
@@ -14,12 +14,13 @@
 
  GNU General Public License for more details.
 

	
 
  You should have received a copy of the GNU General Public License
 
  along with serialplot.  If not, see <http://www.gnu.org/licenses/>.
 
*/
 

	
 
#include <time.h>
 
#define CATCH_CONFIG_MAIN  // This tells Catch to provide a main() - only do this in one cpp file
 
#include "catch.hpp"
 

	
 
#include "datachunk.h"
 
#include "chunkedbuffer.h"
 

	
 
@@ -144,6 +145,28 @@ TEST_CASE("ChunkedBuffer accessing data"
 
    REQUIRE(b.sample(CHUNK_SIZE-1) == 30);
 
    REQUIRE(b.sample(CHUNK_SIZE) == 40);
 
    REQUIRE(b.sample(CHUNK_SIZE+1) == 50);
 
    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)));
 
}
0 comments (0 inline, 0 general)