susumu.yata
null+****@clear*****
Thu Feb 28 11:36:19 JST 2013
susumu.yata 2013-02-28 11:36:19 +0900 (Thu, 28 Feb 2013) New Revision: dcf3fdf798eb4d9e1e1e795e1c52b3538762b2b5 https://github.com/groonga/grnxx/commit/dcf3fdf798eb4d9e1e1e795e1c52b3538762b2b5 Log: Add a test for grnxx::BrokenDownTime. Added files: test/test_broken_down_time.cpp Modified files: .gitignore test/Makefile.am Modified: .gitignore (+1 -0) =================================================================== --- .gitignore 2013-02-28 11:02:53 +0900 (44f2c36) +++ .gitignore 2013-02-28 11:36:19 +0900 (a22f989) @@ -29,6 +29,7 @@ stamp-h1 temp/ test/test_alpha_double_array test/test_backtrace +test/test_broken_down_time test/test_db_blob_vector test/test_db_vector test/test_duration Modified: test/Makefile.am (+4 -0) =================================================================== --- test/Makefile.am 2013-02-28 11:02:53 +0900 (3e3e1b9) +++ test/Makefile.am 2013-02-28 11:36:19 +0900 (4115bff) @@ -3,6 +3,7 @@ AM_CXXFLAGS = @AM_CXXFLAGS@ -I$(top_srcdir)/lib TESTS = \ test_alpha_double_array \ test_backtrace \ + test_broken_down_time \ test_db_blob_vector \ test_db_vector \ test_duration \ @@ -39,6 +40,9 @@ test_alpha_double_array_LDADD = ../lib/libgrnxx.la test_backtrace_SOURCES = test_backtrace.cpp test_backtrace_LDADD = ../lib/libgrnxx.la +test_broken_down_time_SOURCES = test_broken_down_time.cpp +test_broken_down_time_LDADD = ../lib/libgrnxx.la + test_db_blob_vector_SOURCES = test_db_blob_vector.cpp test_db_blob_vector_LDADD = ../lib/libgrnxx.la Added: test/test_broken_down_time.cpp (+57 -0) 100644 =================================================================== --- /dev/null +++ test/test_broken_down_time.cpp 2013-02-28 11:36:19 +0900 (cde8438) @@ -0,0 +1,57 @@ +/* + Copyright (C) 2012-2013 Brazil, Inc. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ +#include <cassert> + +#include "logger.hpp" +#include "steady_clock.hpp" +#include "system_clock.hpp" + +int main() { + grnxx::Logger::set_flags(grnxx::LOGGER_WITH_ALL | + grnxx::LOGGER_ENABLE_COUT); + grnxx::Logger::set_max_level(grnxx::NOTICE_LOGGER); + + GRNXX_NOTICE() << "grnxx::SystemClock::now().universal_time(): " + << grnxx::SystemClock::now().universal_time(); + GRNXX_NOTICE() << "grnxx::SystemClock::now().local_time(): " + << grnxx::SystemClock::now().local_time(); + + enum { LOOP_COUNT = 1 << 16 }; + + grnxx::Time now = grnxx::SystemClock::now(); + + grnxx::Time start = grnxx::SteadyClock::now(); + for (int i = 0; i < LOOP_COUNT; ++i) { + now.universal_time(); + } + grnxx::Time end = grnxx::SteadyClock::now(); + grnxx::Duration elapsed = end - start; + GRNXX_NOTICE() << "grnxx::Time::universal_time(): average elapsed [ns] = " + << (1000.0 * elapsed.count() / LOOP_COUNT); + + start = grnxx::SteadyClock::now(); + for (int i = 0; i < LOOP_COUNT; ++i) { + now.local_time(); + } + end = grnxx::SteadyClock::now(); + elapsed = end - start; + GRNXX_NOTICE() << "grnxx::Time::local_time(): average elapsed [ns] = " + << (1000.0 * elapsed.count() / LOOP_COUNT); + + return 0; +} -------------- next part -------------- HTML����������������������������...Download