diff options
author | Igor Sysoev <igor@sysoev.ru> | 2017-02-22 15:09:59 +0300 |
---|---|---|
committer | Igor Sysoev <igor@sysoev.ru> | 2017-02-22 15:09:59 +0300 |
commit | 029942f4eb7196c2cff0d0e26bc6ff274138f7d8 (patch) | |
tree | f4686c4d7b9cd574fe94c6f4918479a580fecf75 /test | |
parent | 059a8642898a6bd4b47d13a1c1d599cd44af7e1c (diff) | |
download | unit-029942f4eb7196c2cff0d0e26bc6ff274138f7d8.tar.gz unit-029942f4eb7196c2cff0d0e26bc6ff274138f7d8.tar.bz2 |
I/O operations refactoring.
Diffstat (limited to '')
-rw-r--r-- | test/nxt_exp_approximation.c | 72 | ||||
-rw-r--r-- | test/nxt_lib_unit_test.c | 4 | ||||
-rw-r--r-- | test/nxt_lib_unit_test.h | 2 |
3 files changed, 0 insertions, 78 deletions
diff --git a/test/nxt_exp_approximation.c b/test/nxt_exp_approximation.c deleted file mode 100644 index 1f79c068..00000000 --- a/test/nxt_exp_approximation.c +++ /dev/null @@ -1,72 +0,0 @@ - -/* - * Copyright (C) Igor Sysoev - * Copyright (C) NGINX, Inc. - */ - -#include <nxt_main.h> -#include <math.h> - - -nxt_int_t -nxt_exp_approximation(nxt_thread_t *thr) -{ - double n, e0, e1, diff; - nxt_nsec_t start, end; - - nxt_thread_time_update(thr); - nxt_log_error(NXT_LOG_NOTICE, thr->log, - "exp approximation unit test started"); - - for (n = 0.0; n > -20.0; n -= 0.00001) { - - e0 = nxt_event_conn_exponential_approximation(n); - e1 = exp(n); - - diff = fabs(e0 - e1); - - /* 0.028993 is max difference with libm exp(). */ - if (diff > 0.028993) { - nxt_log_alert(thr->log, - "exp approximation unit test failed: %0.6f %0.6f", - n, diff); - return NXT_ERROR; - } - } - - - nxt_thread_time_update(thr); - start = nxt_thread_monotonic_time(thr); - - e0 = 0; - for (n = 0.0; n > -20.0; n -= 0.00001) { - e0 += nxt_event_conn_exponential_approximation(n); - } - - nxt_thread_time_update(thr); - end = nxt_thread_monotonic_time(thr); - - /* e0 is passed but not output to eliminate optimization. */ - nxt_log_error(NXT_LOG_NOTICE, thr->log, "exp approximation: %0.1fns", - (end - start) / 20000000.0, e0); - - - nxt_thread_time_update(thr); - start = nxt_thread_monotonic_time(thr); - - e0 = 0; - for (n = 0.0; n > -20.0; n -= 0.000001) { - e0 += exp(n); - } - - nxt_thread_time_update(thr); - end = nxt_thread_monotonic_time(thr); - - /* e0 is passed but not output to eliminate optimization. */ - nxt_log_error(NXT_LOG_NOTICE, thr->log, "libm exp(): %0.1fns", - (end - start) / 20000000.0, e0); - - nxt_log_error(NXT_LOG_NOTICE, thr->log, - "exp approximation unit test passed"); - return NXT_OK; -} diff --git a/test/nxt_lib_unit_test.c b/test/nxt_lib_unit_test.c index 28397187..876416e5 100644 --- a/test/nxt_lib_unit_test.c +++ b/test/nxt_lib_unit_test.c @@ -77,10 +77,6 @@ main(int argc, char **argv) return 1; } - if (nxt_exp_approximation(thr) != NXT_OK) { - return 1; - } - if (nxt_rbtree_unit_test(thr, 100 * 1000) != NXT_OK) { return 1; } diff --git a/test/nxt_lib_unit_test.h b/test/nxt_lib_unit_test.h index bbb2d5f4..a6a24855 100644 --- a/test/nxt_lib_unit_test.h +++ b/test/nxt_lib_unit_test.h @@ -38,8 +38,6 @@ nxt_rdtsc(void) nxt_int_t nxt_term_parse_unit_test(nxt_thread_t *thr); nxt_int_t nxt_msec_diff_unit_test(nxt_thread_t *thr, nxt_msec_less_t); -nxt_int_t nxt_exp_approximation(nxt_thread_t *thr); -double nxt_event_conn_exponential_approximation(double n); nxt_int_t nxt_rbtree_unit_test(nxt_thread_t *thr, nxt_uint_t n); nxt_int_t nxt_rbtree1_unit_test(nxt_thread_t *thr, nxt_uint_t n); |