From: Adam Dickmeiss Date: Fri, 5 Jan 2007 11:45:11 +0000 (+0000) Subject: Added test of timing_t. X-Git-Tag: YAZ.2.1.46~24 X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=commitdiff_plain;h=a0989999fec1457bdd624ca18915d7cc2b55fd2d Added test of timing_t. --- diff --git a/test/.cvsignore b/test/.cvsignore index aec0b00..021b6cb 100644 --- a/test/.cvsignore +++ b/test/.cvsignore @@ -21,6 +21,4 @@ tst_filepath tst_record_conv tst_retrieval tst_tpath -nfatest1 -nfaxmltest1 -nfaxmltest1.log +tst_timing.log diff --git a/test/Makefile.am b/test/Makefile.am index db2dd19..5d19146 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -1,10 +1,10 @@ ## Copyright (C) 1995-2007, Index Data ApS ## All rights reserved. -## $Id: Makefile.am,v 1.29 2007-01-03 08:42:16 adam Exp $ +## $Id: Makefile.am,v 1.30 2007-01-05 11:45:11 adam Exp $ check_PROGRAMS = tsticonv tstnmem tstmatchstr tstwrbuf tstodr tstccl tstlog \ tstsoap1 tstsoap2 tstodrstack tstlogthread tstxmlquery tstpquery \ - tst_filepath tst_record_conv tst_retrieval tst_tpath + tst_filepath tst_record_conv tst_retrieval tst_tpath tst_timing check_SCRIPTS = tstcql.sh tstmarciso.sh tstmarcxml.sh tstmarccol.sh TESTS = $(check_PROGRAMS) $(check_SCRIPTS) @@ -60,3 +60,4 @@ tst_filepath_SOURCES = tst_filepath.c tst_record_conv_SOURCES = tst_record_conv.c tst_retrieval_SOURCES = tst_retrieval.c tst_tpath_SOURCES = tst_tpath.c +tst_timing_SOURCES = tst_timing.c diff --git a/test/tst_timing.c b/test/tst_timing.c new file mode 100644 index 0000000..c02f03c --- /dev/null +++ b/test/tst_timing.c @@ -0,0 +1,63 @@ +/* + * Copyright (C) 1995-2007, Index Data ApS + * See the file LICENSE for details. + * + * $Id: tst_timing.c,v 1.1 2007-01-05 11:45:11 adam Exp $ + */ + +#include +#include + +#include +#include +#include + +static void tst(void) +{ + yaz_timing_t t = yaz_timing_create(); + double real, user, sys; + int i = 0; + + YAZ_CHECK(t); + if (!t) + return; + + for (i = 0; i<100000; i++) + ; + + YAZ_CHECK_EQ(i, 100000); + + yaz_timing_stop(t); + + real = yaz_timing_get_real(t); + YAZ_CHECK(real == -1.0 || real >= 0.0); + + user = yaz_timing_get_user(t); + YAZ_CHECK(user == -1.0 || user >= 0.0); + + sys = yaz_timing_get_sys(t); + YAZ_CHECK(sys == -1.0 || sys >= 0.0); + + yaz_log(YLOG_LOG, "real=%f user=%f sys=%f", real, user, sys); + + yaz_timing_destroy(&t); + YAZ_CHECK(!t); +} + + +int main (int argc, char **argv) +{ + YAZ_CHECK_INIT(argc, argv); + YAZ_CHECK_LOG(); + tst(); + YAZ_CHECK_TERM; +} + +/* + * Local variables: + * c-basic-offset: 4 + * indent-tabs-mode: nil + * End: + * vim: shiftwidth=4 tabstop=8 expandtab + */ +