diff --git a/Makefile.am b/Makefile.am index 3092d73a..b00357fc 100644 --- a/Makefile.am +++ b/Makefile.am @@ -109,6 +109,7 @@ cleandist: $(distdir)/src/ulib/orm/driver/.libs \ $(distdir)/src/ulib/orm/driver/Makefile \ $(distdir)/src/ulib/orm/driver/libpq/Makefile \ + $(distdir)/src/ulib/orm/driver/libpq/libpq.la \ $(distdir)/src/ulib/net/server/plugin/*.o \ $(distdir)/src/ulib/net/server/plugin/*.l? \ $(distdir)/src/ulib/net/server/plugin/.deps \ diff --git a/Makefile.in b/Makefile.in index 47936dbe..b4a77932 100644 --- a/Makefile.in +++ b/Makefile.in @@ -1032,6 +1032,7 @@ cleandist: $(distdir)/src/ulib/orm/driver/.libs \ $(distdir)/src/ulib/orm/driver/Makefile \ $(distdir)/src/ulib/orm/driver/libpq/Makefile \ + $(distdir)/src/ulib/orm/driver/libpq/libpq.la \ $(distdir)/src/ulib/net/server/plugin/*.o \ $(distdir)/src/ulib/net/server/plugin/*.l? \ $(distdir)/src/ulib/net/server/plugin/.deps \ diff --git a/configure b/configure index 69534bfb..7df94a46 100755 --- a/configure +++ b/configure @@ -775,8 +775,6 @@ TCC_TRUE PRG_LDFLAGS POSTGRESQL_USE_OPENSSL_FALSE POSTGRESQL_USE_OPENSSL_TRUE -HAVE_PGSQL_BATCH_API_FALSE -HAVE_PGSQL_BATCH_API_TRUE HAVE_PGSQL_FALSE HAVE_PGSQL_TRUE POSTGRESQL_LIBS @@ -30414,14 +30412,6 @@ else HAVE_PGSQL_FALSE= fi - if false; then - HAVE_PGSQL_BATCH_API_TRUE= - HAVE_PGSQL_BATCH_API_FALSE='#' -else - HAVE_PGSQL_BATCH_API_TRUE='#' - HAVE_PGSQL_BATCH_API_FALSE= -fi - if false; then POSTGRESQL_USE_OPENSSL_TRUE= POSTGRESQL_USE_OPENSSL_FALSE='#' @@ -30443,87 +30433,6 @@ fi $as_echo "#define USE_PGSQL 1" >>confdefs.h - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing PQenterBatchMode" >&5 -$as_echo_n "checking for library containing PQenterBatchMode... " >&6; } -if ${ac_cv_search_PQenterBatchMode+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_func_search_save_LIBS="$LIBS" -ac_cv_search_PQenterBatchMode="no" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char PQenterBatchMode (); -int -main () -{ -return PQenterBatchMode (); - ; - return 0; -} -_ACEOF -if ac_fn_cxx_try_link "$LINENO"; then : - ac_cv_search_PQenterBatchMode="none required" -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -test "$ac_cv_search_PQenterBatchMode" = "no" && for i in pq; do -LIBS="-l$i $ac_func_search_save_LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char PQenterBatchMode (); -int -main () -{ -return PQenterBatchMode (); - ; - return 0; -} -_ACEOF -if ac_fn_cxx_try_link "$LINENO"; then : - ac_cv_search_PQenterBatchMode="-l$i" -break -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -done -LIBS="$ac_func_search_save_LIBS" -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_PQenterBatchMode" >&5 -$as_echo "$ac_cv_search_PQenterBatchMode" >&6; } -if test "$ac_cv_search_PQenterBatchMode" != "no"; then - test "$ac_cv_search_PQenterBatchMode" = "none required" || POSTGRESQL_LIBS="$POSTGRESQL_LIBS $ac_cv_search_PQenterBatchMode" - -else : - -fi - if test "$ac_cv_search_PQenterBatchMode" = "yes"; then - if true; then - HAVE_PGSQL_BATCH_API_TRUE= - HAVE_PGSQL_BATCH_API_FALSE='#' -else - HAVE_PGSQL_BATCH_API_TRUE='#' - HAVE_PGSQL_BATCH_API_FALSE= -fi - - -$as_echo "#define USE_PGSQL_BATCH_API 1" >>confdefs.h - - fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether PostgreSQL use openssl" >&5 $as_echo_n "checking whether PostgreSQL use openssl... " >&6; } if test -n "`pg_config --configure | grep openssl`"; then @@ -34142,7 +34051,7 @@ fi CXX_MAYBE_FLAGS_MODERN="" if test "$found_postgresql" = "yes"; then - if test "$ac_cv_search_PQenterBatchMode" = "yes"; then + if test "$static_handler_pgsql" != "yes"; then CC_MAYBE_FLAGS="$CC_MAYBE_FLAGS -Wc++-compat -Wold-style-definition" else CC_MAYBE_FLAGS="$CC_MAYBE_FLAGS -Wno-discarded-qualifiers -Wno-switch-enum -Wno-missing-field-initializers -Wno-sign-compare -Wno-strict-aliasing \ @@ -36021,10 +35930,6 @@ if test -z "${HAVE_PGSQL_TRUE}" && test -z "${HAVE_PGSQL_FALSE}"; then as_fn_error $? "conditional \"HAVE_PGSQL\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi -if test -z "${HAVE_PGSQL_BATCH_API_TRUE}" && test -z "${HAVE_PGSQL_BATCH_API_FALSE}"; then - as_fn_error $? "conditional \"HAVE_PGSQL_BATCH_API\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi if test -z "${POSTGRESQL_USE_OPENSSL_TRUE}" && test -z "${POSTGRESQL_USE_OPENSSL_FALSE}"; then as_fn_error $? "conditional \"POSTGRESQL_USE_OPENSSL\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 @@ -36033,10 +35938,6 @@ if test -z "${HAVE_PGSQL_TRUE}" && test -z "${HAVE_PGSQL_FALSE}"; then as_fn_error $? "conditional \"HAVE_PGSQL\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi -if test -z "${HAVE_PGSQL_BATCH_API_TRUE}" && test -z "${HAVE_PGSQL_BATCH_API_FALSE}"; then - as_fn_error $? "conditional \"HAVE_PGSQL_BATCH_API\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi if test -z "${POSTGRESQL_USE_OPENSSL_TRUE}" && test -z "${POSTGRESQL_USE_OPENSSL_FALSE}"; then as_fn_error $? "conditional \"POSTGRESQL_USE_OPENSSL\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 diff --git a/configure.ac b/configure.ac index 706efb98..4d8d0453 100644 --- a/configure.ac +++ b/configure.ac @@ -1433,17 +1433,11 @@ AC_CHECK_MYSQL AX_LIB_POSTGRESQL AM_CONDITIONAL(HAVE_PGSQL, false) -AM_CONDITIONAL(HAVE_PGSQL_BATCH_API, false) AM_CONDITIONAL(POSTGRESQL_USE_OPENSSL, false) if test "$found_postgresql" = "yes"; then AM_CONDITIONAL(HAVE_PGSQL, true) AC_DEFINE(USE_PGSQL, 1, [Define if enable PostgreSQL database support]) - AC_SEARCH_LIBS_VAR([PQenterBatchMode], pq, , , , POSTGRESQL_LIBS) - if test "$ac_cv_search_PQenterBatchMode" = "yes"; then - AM_CONDITIONAL(HAVE_PGSQL_BATCH_API, true) - AC_DEFINE(USE_PGSQL_BATCH_API, 1, [Define if PostgreSQL database support batch API]) - fi AC_MSG_CHECKING([whether PostgreSQL use openssl]) if test -n "`pg_config --configure | grep openssl`"; then AC_MSG_RESULT([yes]) @@ -2424,7 +2418,7 @@ if test "$ac_cv_c_compiler_gnu" = "yes" -a "x$OPERATINGSYSTEM" = xlinux; then CXX_MAYBE_FLAGS_MODERN="" if test "$found_postgresql" = "yes"; then - if test "$ac_cv_search_PQenterBatchMode" = "yes"; then + if test "$static_handler_pgsql" != "yes"; then CC_MAYBE_FLAGS="$CC_MAYBE_FLAGS -Wc++-compat -Wold-style-definition" else CC_MAYBE_FLAGS="$CC_MAYBE_FLAGS -Wno-discarded-qualifiers -Wno-switch-enum -Wno-missing-field-initializers -Wno-sign-compare -Wno-strict-aliasing \ diff --git a/include/ulib/internal/config.h.in b/include/ulib/internal/config.h.in index 0303e771..e1801cc5 100644 --- a/include/ulib/internal/config.h.in +++ b/include/ulib/internal/config.h.in @@ -777,9 +777,6 @@ /* Define if enable PostgreSQL database support */ #undef USE_PGSQL -/* Define if PostgreSQL database support batch API */ -#undef USE_PGSQL_BATCH_API - /* Define if enable php support */ #undef USE_PHP diff --git a/src/ulib/Makefile.am b/src/ulib/Makefile.am index bae5995a..8a65ca26 100644 --- a/src/ulib/Makefile.am +++ b/src/ulib/Makefile.am @@ -10,11 +10,9 @@ EXTRA_DIST = base/* container/* db/* debug/* dynamic/* flex/* internal/* ldap/* if HAVE_PGSQL if STATIC_ORM_DRIVER_PGSQL -if !HAVE_PGSQL_BATCH_API SUBDIRS = orm/driver/libpq endif endif -endif DEFAULT_INCLUDES = -I. -I$(top_builddir)/include @@ -311,10 +309,8 @@ lib@ULIB@_la_LDFLAGS = @ULIB_LIBS@ if STATIC_ORM_DRIVER_PGSQL SRC_CPP += orm/driver/orm_driver_pgsql.cpp -if !HAVE_PGSQL_BATCH_API lib@ULIB@_la_LDFLAGS += $(top_builddir)/src/ulib/orm/driver/libpq/libpq.la @POSTGRESQL_LDFLAGS@ @POSTGRESQL_LIBS@ endif -endif lib@ULIB@_la_LDFLAGS += -version-info 1:0:0 -release @ULIB_VERSION@ diff --git a/src/ulib/Makefile.in b/src/ulib/Makefile.in index edc26c93..48925cd3 100644 --- a/src/ulib/Makefile.in +++ b/src/ulib/Makefile.in @@ -153,7 +153,7 @@ target_triplet = @target@ @STATIC_ORM_DRIVER_SQLITE_TRUE@am__append_63 = orm/driver/orm_driver_sqlite.cpp @STATIC_ORM_DRIVER_MYSQL_TRUE@am__append_64 = orm/driver/orm_driver_mysql.cpp @STATIC_ORM_DRIVER_PGSQL_TRUE@am__append_65 = orm/driver/orm_driver_pgsql.cpp -@HAVE_PGSQL_BATCH_API_FALSE@@STATIC_ORM_DRIVER_PGSQL_TRUE@am__append_66 = $(top_builddir)/src/ulib/orm/driver/libpq/libpq.la @POSTGRESQL_LDFLAGS@ @POSTGRESQL_LIBS@ +@STATIC_ORM_DRIVER_PGSQL_TRUE@am__append_66 = $(top_builddir)/src/ulib/orm/driver/libpq/libpq.la @POSTGRESQL_LDFLAGS@ @POSTGRESQL_LIBS@ @MINGW_TRUE@am__append_67 = -export-symbols $(srcdir)/@ULIB@.def -no-undefined -Wl,ULib-win32-res.o # Handler static http servlet @@ -769,7 +769,7 @@ EXTRA_DIST = base/* container/* db/* debug/* dynamic/* flex/* internal/* ldap/* net/server/plugin/*.cpp net/server/plugin/Makefile.* \ *.cpp all_c.c ULib.pc.in ULib.rc.in utility/bin -@HAVE_PGSQL_BATCH_API_FALSE@@HAVE_PGSQL_TRUE@@STATIC_ORM_DRIVER_PGSQL_TRUE@SUBDIRS = orm/driver/libpq +@HAVE_PGSQL_TRUE@@STATIC_ORM_DRIVER_PGSQL_TRUE@SUBDIRS = orm/driver/libpq DEFAULT_INCLUDES = -I. -I$(top_builddir)/include pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = ULib.pc diff --git a/src/ulib/event/event_db.cpp b/src/ulib/event/event_db.cpp index 0b471a30..23b45db5 100644 --- a/src/ulib/event/event_db.cpp +++ b/src/ulib/event/event_db.cpp @@ -39,7 +39,9 @@ void UEventDB::addClientImage(vPFpvu handlerResult, uint32_t num_query) (void) U_SYSCALL(PQflush, "%p", (PGconn*)conn); #endif +#if defined(U_SERVER_CAPTIVE_PORTAL) && defined(ENABLE_THREAD) UClientImage_Base::setRequestProcessed(); +#endif U_INTERNAL_DUMP("start = %u end = %u", start, end) diff --git a/src/ulib/net/server/plugin/usp/json.usp b/src/ulib/net/server/plugin/usp/json.usp index 8d33b65a..5c2d6359 100644 --- a/src/ulib/net/server/plugin/usp/json.usp +++ b/src/ulib/net/server/plugin/usp/json.usp @@ -3,6 +3,7 @@ Test type 1: JSON serialization TechEmpower Web Framework Benchmarks --> diff --git a/src/ulib/orm/driver/loader.autoconf.cpp b/src/ulib/orm/driver/loader.autoconf.cpp index 8b137891..bd5db09f 100644 --- a/src/ulib/orm/driver/loader.autoconf.cpp +++ b/src/ulib/orm/driver/loader.autoconf.cpp @@ -1 +1,2 @@ - + + loadStaticLinkedModules(U_STRING_FROM_CONSTANT("pgsql")); diff --git a/tests/.function b/tests/.function index 82fbcbca..f7ec04bb 100644 --- a/tests/.function +++ b/tests/.function @@ -105,12 +105,25 @@ set_ADDRESS() { # function : prepare_usp prepare_usp() { +# rm -f db.la query.la update.la fortune.la cached_worlds.la \ +# mdb.la mquery.la mupdate.la mfortune.la \ +# rdb.la rquery.la rupdate.la rfortune.la \ +# edb.la equery.la eupdate.la; \ +# AM_LDFLAGS="-lWorld" make db.la query.la update.la cached_worlds.la 2>&1; \ +# AM_LDFLAGS="-lWorld -lWorldNoSql" make mdb.la mquery.la mupdate.la 2>&1; \ +# AM_LDFLAGS="-lWorld -lWorldNoSql" make rdb.la rquery.la rupdate.la 2>&1; \ +# AM_LDFLAGS="-lWorld -lWorldNoSql" make edb.la equery.la eupdate.la 2>&1; \ +# AM_LDFLAGS="-lFortune" make fortune.la 2>&1; \ +# AM_LDFLAGS="-lFortune -lFortuneNoSql" make mfortune.la 2>&1; \ +# AM_LDFLAGS="-lFortune -lFortuneNoSql" make rfortune.la 2>&1; \ + if [ "$TERM" != "cygwin" ]; then if [ ! -d ../db ]; then mkdir -p ../db fi rm -f ../db/session.ssl.jnl - ( cd ../../src/ulib/net/server/plugin/usp/; ./usp2so.sh >/tmp/usp2so.sh.out 2>&1 || exit 1; \ + ( cd ../../src/ulib/net/server/plugin/usp/; make; \ + ./usp2so.sh >/tmp/usp2so.sh.out 2>&1 || exit 1; \ test -d ../.libs && cd ../.libs; \ ln -sf ../v8/.libs/server_plugin_v8.so; \ ln -sf ../php/.libs/server_plugin_php.so; \ diff --git a/tests/examples/FrameworkBenchmarks.sh b/tests/examples/FrameworkBenchmarks.sh index a16299ad..f89577f0 100755 --- a/tests/examples/FrameworkBenchmarks.sh +++ b/tests/examples/FrameworkBenchmarks.sh @@ -32,36 +32,36 @@ export ORM_DRIVER ORM_OPTION UMEMPOOL #Running 15s test @ http://localhost:8080/plaintext # 4 threads and 256 connections # Thread Stats Avg Stdev Max +/- Stdev -# Latency 0.91ms 564.97us 25.85ms 97.24% -# Req/Sec 615.24k 52.86k 0.90M 75.81% +# Latency 0.91ms 208.81us 11.38ms 80.51% +# Req/Sec 606.98k 39.03k 699.20k 71.14% # Latency Distribution -# 50% 0.86ms -# 75% 0.95ms -# 90% 1.04ms -# 99% 1.80ms -# 34769232 requests in 15.00s, 4.18GB read -#Requests/sec: 2318061.92 -#Transfer/sec: 285.18MB +# 50% 0.90ms +# 75% 1.01ms +# 90% 1.11ms +# 99% 1.76ms +# 34226368 requests in 14.94s, 4.11GB read +#Requests/sec: 2290284.44 +#Transfer/sec: 281.76MB # ---------------------------------------------------------------------------------------------------------------------------------------------------------- # JSON # ---------------------------------------------------------------------------------------------------------------------------------------------------------- - UMEMPOOL="237,0,0,49,273,-15,-14,-20,36" - sed -i "s|TCP_LINGER_SET .*|TCP_LINGER_SET 0|g" benchmark/FrameworkBenchmarks/fbenchmark.cfg - sed -i "s|LISTEN_BACKLOG .*|LISTEN_BACKLOG 256|g" benchmark/FrameworkBenchmarks/fbenchmark.cfg +#UMEMPOOL="237,0,0,49,273,-15,-14,-20,36" +#sed -i "s|TCP_LINGER_SET .*|TCP_LINGER_SET 0|g" benchmark/FrameworkBenchmarks/fbenchmark.cfg +#sed -i "s|LISTEN_BACKLOG .*|LISTEN_BACKLOG 256|g" benchmark/FrameworkBenchmarks/fbenchmark.cfg # ---------------------------------------------------------------------------------------------------------------------------------------------------------- #Running 15s test @ http://localhost:8080/json # 4 threads and 256 connections # Thread Stats Avg Stdev Max +/- Stdev -# Latency 404.71us 577.61us 13.07ms 98.46% -# Req/Sec 92.85k 19.62k 174.55k 79.88% +# Latency 353.08us 168.28us 8.74ms 84.43% +# Req/Sec 93.33k 8.35k 167.78k 68.27% # Latency Distribution -# 50% 333.00us -# 75% 458.00us -# 90% 581.00us -# 99% 1.86ms -# 5256998 requests in 15.00s, 747.01MB read -#Requests/sec: 350480.62 -#Transfer/sec: 49.80MB +# 50% 327.00us +# 75% 451.00us +# 90% 516.00us +# 99% 745.00us +# 5280348 requests in 15.00s, 750.32MB read +#Requests/sec: 352026.18 +#Transfer/sec: 50.02MB # ---------------------------------------------------------------------------------------------------------------------------------------------------------- # DB # ---------------------------------------------------------------------------------------------------------------------------------------------------------- @@ -69,53 +69,67 @@ export ORM_DRIVER ORM_OPTION UMEMPOOL #ORM_OPTION="host=localhost dbname=../db/hello_world" #ORM_DRIVER="mysql" #ORM_OPTION="host=localhost user=benchmarkdbuser password=benchmarkdbpass character-set=utf8 dbname=hello_world" -#ORM_DRIVER="pgsql" -#ORM_OPTION="host=localhost user=benchmarkdbuser password=benchmarkdbpass dbname=hello_world" -#UMEMPOOL="545,0,0,49,275,-14,-13,-25,41" -#sed -i "s|TCP_LINGER_SET .*|TCP_LINGER_SET -2|g" benchmark/FrameworkBenchmarks/fbenchmark.cfg -#sed -i "s|LISTEN_BACKLOG .*|LISTEN_BACKLOG 256|g" benchmark/FrameworkBenchmarks/fbenchmark.cfg + ORM_DRIVER="pgsql" + ORM_OPTION="host=localhost user=benchmarkdbuser password=benchmarkdbpass dbname=hello_world" + UMEMPOOL="581,0,0,66,16416,-7,-20,-23,31" + sed -i "s|TCP_LINGER_SET .*|TCP_LINGER_SET -2|g" benchmark/FrameworkBenchmarks/fbenchmark.cfg + sed -i "s|LISTEN_BACKLOG .*|LISTEN_BACKLOG 256|g" benchmark/FrameworkBenchmarks/fbenchmark.cfg # ---------------------------------------------------------------------------------------------------------------------------------------------------------- #Running 15s test @ http://localhost:8080/fortune # 4 threads and 256 connections # Thread Stats Avg Stdev Max +/- Stdev -# Latency 0.97ms 444.01us 7.95ms 66.95% -# Req/Sec 35.76k 4.13k 53.33k 62.05% +# Latency 5.97ms 2.42ms 16.39ms 94.85% +# Req/Sec 8.63k 2.15k 11.82k 92.32% # Latency Distribution -# 50% 0.93ms -# 75% 1.26ms -# 90% 1.56ms -# 99% 2.16ms -# 2023409 requests in 15.00s, 2.53GB read -#Requests/sec: 134905.88 -#Transfer/sec: 172.91MB +# 50% 5.21ms +# 75% 6.09ms +# 90% 6.47ms +# 99% 16.39ms +# 520090 requests in 16.00s, 674.06MB read +#Requests/sec: 32502.85 +#Transfer/sec: 42.13MB # #Running 15s test @ http://localhost:8080/db # 4 threads and 256 connections # Thread Stats Avg Stdev Max +/- Stdev -# Latency 663.80us 318.91us 22.24ms 74.68% -# Req/Sec 51.90k 4.80k 69.00k 76.78% +# Latency 5.59ms 1.04ms 11.43ms 78.71% +# Req/Sec 9.25k 1.44k 12.09k 90.49% # Latency Distribution -# 50% 631.00us -# 75% 839.00us -# 90% 1.04ms -# 99% 1.47ms -# 2917228 requests in 15.00s, 425.05MB read -#Requests/sec: 194484.25 -#Transfer/sec: 28.34MB +# 50% 5.69ms +# 75% 6.05ms +# 90% 6.39ms +# 99% 11.05ms +# 539816 requests in 16.01s, 78.25MB read +#Requests/sec: 33720.45 +#Transfer/sec: 4.89MB # #Running 15s test @ http://localhost:8080/query?queries=20 # 4 threads and 256 connections # Thread Stats Avg Stdev Max +/- Stdev -# Latency 2.44ms 1.20ms 32.83ms 68.96% -# Req/Sec 14.40k 2.68k 24.89k 68.36% +# Latency 30.71ms 1.41ms 37.71ms 75.83% +# Req/Sec 1.34k 355.28 2.00k 62.54% # Latency Distribution -# 50% 2.31ms -# 75% 3.16ms -# 90% 4.05ms -# 99% 5.66ms -# 817586 requests in 15.00s, 592.28MB read -#Requests/sec: 54503.98 -#Transfer/sec: 39.48MB +# 50% 30.01ms +# 75% 31.05ms +# 90% 33.01ms +# 99% 34.28ms +# 59809 requests in 16.02s, 43.63MB read +#Requests/sec: 3734.19 +#Transfer/sec: 2.72MB +# +#Running 15s test @ http://localhost:8080/update?queries=20 +# 4 threads and 256 connections +# Thread Stats Avg Stdev Max +/- Stdev +# Latency 979.35ms 123.76ms 1.23s 74.15% +# Req/Sec 37.42 25.76 70.00 52.78% +# Latency Distribution +# 50% 954.28ms +# 75% 1.03s +# 90% 1.23s +# 99% 1.23s +# 1263 requests in 16.01s, 0.92MB read +#Requests/sec: 78.89 +#Transfer/sec: 58.70KB # ---------------------------------------------------------------------------------------------------------------------------------------------------------- #export REDIS_HOST=localhost #UMEMPOOL="1261,0,0,49,274,-14,-15,-24,40" @@ -143,7 +157,7 @@ export ORM_DRIVER ORM_OPTION UMEMPOOL # ---------------------------------------------------------------------------------------------------------------------------------------------------------- DIR_CMD="../../examples/userver" -prepare_usp +#prepare_usp mkdir -p $DOC_ROOT @@ -151,23 +165,27 @@ mkdir -p $DOC_ROOT # ln -sf ../../../docroot/servlet; \ # ln -sf ../../../docroot/100.html; \ # ln -sf ../../../docroot/1000.html; \ +# ln -sf ../../../../../../src/ulib/net/server/plugin/usp/.libs/rdb.so; \ +# ln -sf ../../../../../../src/ulib/net/server/plugin/usp/.libs/mdb.so; \ +# ln -sf ../../../../../../src/ulib/net/server/plugin/usp/.libs/rupdate.so; \ +# ln -sf ../../../../../../src/ulib/net/server/plugin/usp/.libs/mupdate.so; \ +# ln -sf ../../../../../../src/ulib/net/server/plugin/usp/.libs/rquery.so; \ +# ln -sf ../../../../../../src/ulib/net/server/plugin/usp/.libs/mquery.so; \ +# ln -sf ../../../../../../src/ulib/net/server/plugin/usp/.libs/rfortune.so; \ +# ln -sf ../../../../../../src/ulib/net/server/plugin/usp/.libs/mfortune.so; + +# make json.la plaintext.la +#AM_LDFLAGS="-lWorld" make db.la query.la update.la cached_worlds.la +#AM_LDFLAGS="-lFortune" make fortune.la if [ "$TERM" != "cygwin" ]; then ( cd $DOC_ROOT; rm -f *; \ ln -sf ../../../../../../src/ulib/net/server/plugin/usp/.libs/json.so; \ ln -sf ../../../../../../src/ulib/net/server/plugin/usp/.libs/plaintext.so; \ - ln -sf ../../../../../../src/ulib/net/server/plugin/usp/.libs/db.so; \ - ln -sf ../../../../../../src/ulib/net/server/plugin/usp/.libs/rdb.so; \ - ln -sf ../../../../../../src/ulib/net/server/plugin/usp/.libs/mdb.so; \ - ln -sf ../../../../../../src/ulib/net/server/plugin/usp/.libs/update.so; \ - ln -sf ../../../../../../src/ulib/net/server/plugin/usp/.libs/rupdate.so; \ - ln -sf ../../../../../../src/ulib/net/server/plugin/usp/.libs/mupdate.so; \ ln -sf ../../../../../../src/ulib/net/server/plugin/usp/.libs/query.so; \ - ln -sf ../../../../../../src/ulib/net/server/plugin/usp/.libs/rquery.so; \ - ln -sf ../../../../../../src/ulib/net/server/plugin/usp/.libs/mquery.so; \ - ln -sf ../../../../../../src/ulib/net/server/plugin/usp/.libs/fortune.so; \ - ln -sf ../../../../../../src/ulib/net/server/plugin/usp/.libs/rfortune.so; \ - ln -sf ../../../../../../src/ulib/net/server/plugin/usp/.libs/mfortune.so ) + ln -sf ../../../../../../src/ulib/net/server/plugin/usp/.libs/db.so; \ + ln -sf ../../../../../../src/ulib/net/server/plugin/usp/.libs/update.so; \ + ln -sf ../../../../../../src/ulib/net/server/plugin/usp/.libs/fortune.so ) fi # ---------------------------------------------------------------------------------------------------------------------------------------------------------- diff --git a/tests/examples/TSA/tsaserial b/tests/examples/TSA/tsaserial index eea78fa9..60c0080b 100644 --- a/tests/examples/TSA/tsaserial +++ b/tests/examples/TSA/tsaserial @@ -1 +1 @@ -0230 +023E diff --git a/tests/examples/benchmark/FrameworkBenchmarks/ULib/src/db.usp b/tests/examples/benchmark/FrameworkBenchmarks/ULib/src/db.usp index 40ad6246..705fc42a 100644 --- a/tests/examples/benchmark/FrameworkBenchmarks/ULib/src/db.usp +++ b/tests/examples/benchmark/FrameworkBenchmarks/ULib/src/db.usp @@ -5,26 +5,33 @@ TechEmpower Web Framework Benchmarks diff --git a/tests/examples/benchmark/FrameworkBenchmarks/ULib/src/fortune.h b/tests/examples/benchmark/FrameworkBenchmarks/ULib/src/fortune.h index c6b67155..74947785 100644 --- a/tests/examples/benchmark/FrameworkBenchmarks/ULib/src/fortune.h +++ b/tests/examples/benchmark/FrameworkBenchmarks/ULib/src/fortune.h @@ -11,238 +11,347 @@ #include #ifdef U_STATIC_ORM_DRIVER_PGSQL +# include # include #endif -class Fortune { +class U_EXPORT Fortune { public: - uint32_t id; - UString message; + // Check for memory error + U_MEMORY_TEST - Fortune(uint32_t _id) : id(_id), message(101U) - { - U_TRACE_CTOR(5, Fortune, "%u", _id) - } + // Allocator e Deallocator + U_MEMORY_ALLOCATOR + U_MEMORY_DEALLOCATOR - Fortune(uint32_t _id, const UString& _message) : id(_id), message(_message) - { - U_TRACE_CTOR(5, Fortune, "%u,%V", _id, _message.rep) - } + uint32_t id; + UString message; - Fortune(const Fortune& f) : id(f.id), message(f.message) - { - U_TRACE_CTOR(5, Fortune, "%p", &f) + Fortune(uint32_t _id) : id(_id), message(101U) + { + U_TRACE_CTOR(5, Fortune, "%u", _id) + } - U_MEMORY_TEST_COPY(f) - } + Fortune(uint32_t _id, const UString& _message) : id(_id), message(_message) + { + U_TRACE_CTOR(5, Fortune, "%u,%V", _id, _message.rep) + } - ~Fortune() - { - U_TRACE_DTOR(5, Fortune) - } + Fortune(const Fortune& f) : id(f.id), message(f.message) + { + U_TRACE_CTOR(5, Fortune, "%p", &f) - // SERVICE + U_MEMORY_TEST_COPY(f) + } - bool operator<(const Fortune& other) const { return cmp_obj(&message, &other.message); } + ~Fortune() + { + U_TRACE_DTOR(5, Fortune) + } - static int cmp_obj(const void* a, const void* b) - { - U_TRACE(5, "Fortune::cmp_obj(%p,%p)", a, b) + // SERVICE -# ifdef U_STDCPP_ENABLE - /** - * The comparison function must follow a strict-weak-ordering - * - * 1) For all x, it is not the case that x < x (irreflexivity) - * 2) For all x, y, if x < y then it is not the case that y < x (asymmetry) - * 3) For all x, y, and z, if x < y and y < z then x < z (transitivity) - * 4) For all x, y, and z, if x is incomparable with y, and y is incomparable with z, then x is incomparable with z (transitivity of incomparability) - */ + bool operator<(const Fortune& other) const { return cmp_obj(&message, &other.message); } - return (((const Fortune*)a)->message.compare(((const Fortune*)b)->message) < 0); -# else - return (*(const Fortune**)a)->message.compare((*(const Fortune**)b)->message); -# endif - } + static int cmp_obj(const void* a, const void* b) + { + U_TRACE(5, "Fortune::cmp_obj(%p,%p)", a, b) - // JSON +# ifdef U_STDCPP_ENABLE + /** + * The comparison function must follow a strict-weak-ordering + * + * 1) For all x, it is not the case that x < x (irreflexivity) + * 2) For all x, y, if x < y then it is not the case that y < x (asymmetry) + * 3) For all x, y, and z, if x < y and y < z then x < z (transitivity) + * 4) For all x, y, and z, if x is incomparable with y, and y is incomparable with z, then x is incomparable with z (transitivity of incomparability) + */ - void toJSON(UString& json) - { - U_TRACE(5, "Fortune::toJSON(%V)", json.rep) + return (((const Fortune*)a)->message.compare(((const Fortune*)b)->message) < 0); +# else + return (*(const Fortune**)a)->message.compare((*(const Fortune**)b)->message); +# endif + } - json.toJSON(U_JSON_METHOD_HANDLER(id, unsigned int)); - json.toJSON(U_JSON_METHOD_HANDLER(message, UString)); - } + // JSON - void fromJSON(UValue& json) - { - U_TRACE(5, "Fortune::fromJSON(%p)", &json) + void toJSON(UString& json) + { + U_TRACE(5, "Fortune::toJSON(%V)", json.rep) - json.fromJSON(U_JSON_METHOD_HANDLER(id, unsigned int)); - json.fromJSON(U_JSON_METHOD_HANDLER(message, UString)); - } + json.toJSON(U_JSON_METHOD_HANDLER(id, unsigned int)); + json.toJSON(U_JSON_METHOD_HANDLER(message, UString)); + } - // ORM + void fromJSON(UValue& json) + { + U_TRACE(5, "Fortune::fromJSON(%p)", &json) - void bindParam(UOrmStatement* stmt) - { - U_TRACE(5, "Fortune::bindParam(%p)", stmt) + json.fromJSON(U_JSON_METHOD_HANDLER(id, unsigned int)); + json.fromJSON(U_JSON_METHOD_HANDLER(message, UString)); + } - stmt->bindParam(U_ORM_TYPE_HANDLER(id, unsigned int)); - stmt->bindParam(U_ORM_TYPE_HANDLER(message, UString)); - } + // ORM - void bindResult(UOrmStatement* stmt) - { - U_TRACE(5, "Fortune::bindResult(%p)", stmt) + void bindParam(UOrmStatement* stmt) + { + U_TRACE(5, "Fortune::bindParam(%p)", stmt) - stmt->bindResult(U_ORM_TYPE_HANDLER(id, unsigned int)); - stmt->bindResult(U_ORM_TYPE_HANDLER(message, UString)); - } + stmt->bindParam(U_ORM_TYPE_HANDLER(id, unsigned int)); + stmt->bindParam(U_ORM_TYPE_HANDLER(message, UString)); + } - static uint32_t uid; - static UString* pmessage; - static UVector* pvfortune; + void bindResult(UOrmStatement* stmt) + { + U_TRACE(5, "Fortune::bindResult(%p)", stmt) - static UOrmSession* psql_fortune; - static UOrmStatement* pstmt_fortune; + stmt->bindResult(U_ORM_TYPE_HANDLER(id, unsigned int)); + stmt->bindResult(U_ORM_TYPE_HANDLER(message, UString)); + } - static void replace(uint32_t i, uint32_t _id, const char* msg, uint32_t len) - { - U_TRACE(5, "Fortune::replace(%u,%u,%.*S,%u)", i, _id, len, msg, len) + static uint32_t uid; + static char* pwbuffer; + static UString* pmessage; + static UVector* pvfortune; - U_INTERNAL_ASSERT_POINTER(pvfortune) + static UOrmSession* psql_fortune; + static UOrmStatement* pstmt_fortune; - Fortune* elem = pvfortune->at(i); +#ifdef U_STATIC_ORM_DRIVER_PGSQL + static PGconn* conn; + static UOrmDriverPgSql* pdrv; + static UPgSqlStatement* pstmt; - elem->id = _id; + static PGresult* execPrepared() + { + U_TRACE_NO_PARAM(5, "Fortune::execPrepared()") - UXMLEscape::encode(msg, len, elem->message); - } + PGresult* res = (PGresult*) U_SYSCALL(PQexecPrepared, "%p,%S,%u,%p,%p,%p,%u", conn, pstmt->stmtName, 0, 0, 0, 0, 1); - static void replace(uint32_t i) { replace(i, uid, U_STRING_TO_PARAM(*pmessage)); } - static void replace(uint32_t i, uint32_t _id) { replace(i, _id, U_STRING_TO_PARAM(*pmessage)); } - static void replace(uint32_t i, const UString& message) { replace(i, i+1, U_STRING_TO_PARAM(message)); } - static void replace(uint32_t i, uint32_t _id, const UString& message) { replace(i, _id, U_STRING_TO_PARAM(message)); } + U_RETURN_POINTER(res, PGresult); + } - static void doQuery(vPF handlerQuery) - { - U_TRACE(5, "Fortune::doQuery(%p)", handlerQuery) + static void sendQueryPrepared() + { + U_TRACE_NO_PARAM(5, "Fortune::sendQueryPrepared()") - U_INTERNAL_ASSERT_POINTER(pvfortune) + (void) U_SYSCALL(PQsendQueryPrepared, "%p,%S,%u,%p,%p,%p,%u", conn, pstmt->stmtName, 0, 0, 0, 0, 1); + } +#endif - char* pwbuffer = UClientImage_Base::wbuffer->data(); + static void replace(uint32_t i, uint32_t _id, const char* msg, uint32_t len) + { + U_TRACE(5, "Fortune::replace(%u,%u,%.*S,%u)", i, _id, len, msg, len) - u_put_unalignedp64(pwbuffer, U_MULTICHAR_CONSTANT64('C','o','n','t','e','n','t','-')); - u_put_unalignedp64(pwbuffer+8, U_MULTICHAR_CONSTANT64('L','e','n','g','t','h',':',' ')); - u_put_unalignedp64(pwbuffer+16, U_MULTICHAR_CONSTANT64('1','2','2','7','\r','\n','C','o')); - u_put_unalignedp64(pwbuffer+24, U_MULTICHAR_CONSTANT64('n','t','e','n','t','-','T','y')); - u_put_unalignedp64(pwbuffer+32, U_MULTICHAR_CONSTANT64('p','e',':',' ','t','e','x','t')); - u_put_unalignedp64(pwbuffer+40, U_MULTICHAR_CONSTANT64('/','h','t','m','l',';',' ','c')); - u_put_unalignedp64(pwbuffer+48, U_MULTICHAR_CONSTANT64('h','a','r','s','e','t','=','U')); - u_put_unalignedp64(pwbuffer+56, U_MULTICHAR_CONSTANT64('T','F','-','8','\r','\n','\r','\n')); - u_put_unalignedp64(pwbuffer+64, U_MULTICHAR_CONSTANT64('<','!','d','o','c','t','y','p')); - u_put_unalignedp64(pwbuffer+72, U_MULTICHAR_CONSTANT64('e',' ','h','t','m','l','>','<')); - u_put_unalignedp64(pwbuffer+80, U_MULTICHAR_CONSTANT64('h','t','m','l','>','<','h','e')); - u_put_unalignedp64(pwbuffer+88, U_MULTICHAR_CONSTANT64('a','d','>','<','t','i','t','l')); - u_put_unalignedp64(pwbuffer+96, U_MULTICHAR_CONSTANT64('e','>','F','o','r','t','u','n')); - u_put_unalignedp64(pwbuffer+104, U_MULTICHAR_CONSTANT64('e','s','<','/','t','i','t','l')); - u_put_unalignedp64(pwbuffer+112, U_MULTICHAR_CONSTANT64('e','>','<','/','h','e','a','d')); - u_put_unalignedp64(pwbuffer+120, U_MULTICHAR_CONSTANT64('>','<','b','o','d','y','>','<')); - u_put_unalignedp64(pwbuffer+128, U_MULTICHAR_CONSTANT64('t','a','b','l','e','>','<','t')); - u_put_unalignedp64(pwbuffer+136, U_MULTICHAR_CONSTANT64('r','>','<','t','h','>','i','d')); - u_put_unalignedp64(pwbuffer+144, U_MULTICHAR_CONSTANT64('<','/','t','h','>','<','t','h')); - u_put_unalignedp64(pwbuffer+152, U_MULTICHAR_CONSTANT64('>','m','e','s','s','a','g','e')); - u_put_unalignedp64(pwbuffer+160, U_MULTICHAR_CONSTANT64('<','/','t','h','>','<','/','t')); - u_put_unalignedp16(pwbuffer+168, U_MULTICHAR_CONSTANT16('r','>')); + U_INTERNAL_ASSERT_POINTER(pvfortune) - pwbuffer += U_CONSTANT_SIZE("Content-Length: 1227\r\nContent-Type: text/html; charset=UTF-8\r\n\r\n" - "Fortunes"); + Fortune* elem = pvfortune->at(i); - handlerQuery(); + elem->id = _id; - Fortune* elem = pvfortune->last(); + UXMLEscape::encode(msg, len, elem->message); + } - elem->id = 0; - elem->message.rep->replace(U_CONSTANT_TO_PARAM("Additional fortune added at request time.")); + static void replace(uint32_t i) { replace(i, uid, U_STRING_TO_PARAM(*pmessage)); } + static void replace(uint32_t i, uint32_t _id) { replace(i, _id, U_STRING_TO_PARAM(*pmessage)); } + static void replace(uint32_t i, const UString& message) { replace(i, i+1, U_STRING_TO_PARAM(message)); } + static void replace(uint32_t i, uint32_t _id, const UString& message) { replace(i, _id, U_STRING_TO_PARAM(message)); } - pvfortune->sort(Fortune::cmp_obj); + static void initQuery() + { + U_TRACE_NO_PARAM(5, "::initQuery()") - for (uint32_t sz, i = 0, n = pvfortune->size(); i < n; ++i) - { - elem = pvfortune->at(i); + char* ptr = UClientImage_Base::wbuffer->data(); - u_put_unalignedp64(pwbuffer, U_MULTICHAR_CONSTANT64('<','t','r','>','<','t','d','>')); + U_INTERNAL_DUMP("wbuffer(%u) = %#.10S", UClientImage_Base::wbuffer->size(), ptr) - pwbuffer = u_num2str32(elem->id, pwbuffer+8); + if (*ptr == '\0') + { + u_put_unalignedp64(ptr, U_MULTICHAR_CONSTANT64('C','o','n','t','e','n','t','-')); + u_put_unalignedp64(ptr+8, U_MULTICHAR_CONSTANT64('L','e','n','g','t','h',':',' ')); + u_put_unalignedp64(ptr+16, U_MULTICHAR_CONSTANT64('1','2','2','7','\r','\n','C','o')); + u_put_unalignedp64(ptr+24, U_MULTICHAR_CONSTANT64('n','t','e','n','t','-','T','y')); + u_put_unalignedp64(ptr+32, U_MULTICHAR_CONSTANT64('p','e',':',' ','t','e','x','t')); + u_put_unalignedp64(ptr+40, U_MULTICHAR_CONSTANT64('/','h','t','m','l',';',' ','c')); + u_put_unalignedp64(ptr+48, U_MULTICHAR_CONSTANT64('h','a','r','s','e','t','=','U')); + u_put_unalignedp64(ptr+56, U_MULTICHAR_CONSTANT64('T','F','-','8','\r','\n','\r','\n')); + u_put_unalignedp64(ptr+64, U_MULTICHAR_CONSTANT64('<','!','d','o','c','t','y','p')); + u_put_unalignedp64(ptr+72, U_MULTICHAR_CONSTANT64('e',' ','h','t','m','l','>','<')); + u_put_unalignedp64(ptr+80, U_MULTICHAR_CONSTANT64('h','t','m','l','>','<','h','e')); + u_put_unalignedp64(ptr+88, U_MULTICHAR_CONSTANT64('a','d','>','<','t','i','t','l')); + u_put_unalignedp64(ptr+96, U_MULTICHAR_CONSTANT64('e','>','F','o','r','t','u','n')); + u_put_unalignedp64(ptr+104, U_MULTICHAR_CONSTANT64('e','s','<','/','t','i','t','l')); + u_put_unalignedp64(ptr+112, U_MULTICHAR_CONSTANT64('e','>','<','/','h','e','a','d')); + u_put_unalignedp64(ptr+120, U_MULTICHAR_CONSTANT64('>','<','b','o','d','y','>','<')); + u_put_unalignedp64(ptr+128, U_MULTICHAR_CONSTANT64('t','a','b','l','e','>','<','t')); + u_put_unalignedp64(ptr+136, U_MULTICHAR_CONSTANT64('r','>','<','t','h','>','i','d')); + u_put_unalignedp64(ptr+144, U_MULTICHAR_CONSTANT64('<','/','t','h','>','<','t','h')); + u_put_unalignedp64(ptr+152, U_MULTICHAR_CONSTANT64('>','m','e','s','s','a','g','e')); + u_put_unalignedp64(ptr+160, U_MULTICHAR_CONSTANT64('<','/','t','h','>','<','/','t')); + u_put_unalignedp16(ptr+168, U_MULTICHAR_CONSTANT16('r','>')); - u_put_unalignedp64(pwbuffer, U_MULTICHAR_CONSTANT64('<','/','t','d','>','<','t','d')); - pwbuffer += 8; + pwbuffer = ptr + U_CONSTANT_SIZE("Content-Length: 1227\r\nContent-Type: text/html; charset=UTF-8\r\n\r\n" + "Fortunes
idmessage
"); - *pwbuffer++ = '>'; + UClientImage_Base::wbuffer->size_adjust_constant(U_CONSTANT_SIZE("Content-Length: 1227\r\nContent-Type: text/html; charset=UTF-8\r\n\r\n") + 1227); + } - (void) memcpy(pwbuffer, elem->message.data(), sz = elem->message.size()); - pwbuffer += sz; + U_INTERNAL_ASSERT_EQUALS(u_get_unalignedp64(UClientImage_Base::wbuffer->data()), U_MULTICHAR_CONSTANT64('C','o','n','t','e','n','t','-')) + U_INTERNAL_ASSERT_EQUALS(u_get_unalignedp64(UClientImage_Base::wbuffer->c_pointer(48)), U_MULTICHAR_CONSTANT64('h','a','r','s','e','t','=','U')) + } - u_put_unalignedp64(pwbuffer, U_MULTICHAR_CONSTANT64('<','/','t','d','>','<','/','t')); - u_put_unalignedp16(pwbuffer+8, U_MULTICHAR_CONSTANT16('r','>')); - pwbuffer += 8+2; - } + static void endQuery() + { + U_TRACE_NO_PARAM(5, "::endQuery()") - u_put_unalignedp64(pwbuffer, U_MULTICHAR_CONSTANT64('<','/','t','a','b','l','e','>')); - u_put_unalignedp64(pwbuffer+8, U_MULTICHAR_CONSTANT64('<','/','b','o','d','y','>','<')); - u_put_unalignedp64(pwbuffer+16, U_MULTICHAR_CONSTANT64('/','h','t','m','l','>','\0','\0')); + U_INTERNAL_ASSERT_POINTER(pvfortune) - UClientImage_Base::wbuffer->size_adjust_constant(pwbuffer + U_CONSTANT_SIZE("
idmessage
")); - } + Fortune* elem = pvfortune->last(); - static void handlerFork() - { - U_TRACE_NO_PARAM(5, "Fortune::handlerFork()") + elem->id = 0; + elem->message.rep->replace(U_CONSTANT_TO_PARAM("Additional fortune added at request time.")); - U_NEW_STRING(pmessage, UString(101U)); + pvfortune->sort(Fortune::cmp_obj); - U_NEW(UVector, pvfortune, UVector); + char* ptr = pwbuffer; - Fortune* elem; + for (uint32_t sz, i = 0, n = pvfortune->size(); i < n; ++i) + { + elem = pvfortune->at(i); - for (uint32_t i = 0; i < 13; ++i) - { - U_NEW(Fortune, elem, Fortune(i+1)); + u_put_unalignedp64(ptr, U_MULTICHAR_CONSTANT64('<','t','r','>','<','t','d','>')); - pvfortune->push(elem); - } - } + ptr = u_num2str32(elem->id, ptr+8); - static void handlerForkSql() - { - U_TRACE_NO_PARAM(5, "Fortune::handlerForkSql()") + u_put_unalignedp64(ptr, U_MULTICHAR_CONSTANT64('<','/','t','d','>','<','t','d')); + ptr += 8; - if (psql_fortune == U_NULLPTR) - { - U_NEW(UOrmSession, psql_fortune, UOrmSession(U_CONSTANT_TO_PARAM("fortune"))); + *ptr++ = '>'; - if (psql_fortune->isReady() == false) - { - U_WARNING("Fortune::handlerForkSql(): we cound't connect to db"); + (void) memcpy(ptr, elem->message.data(), sz = elem->message.size()); + ptr += sz; - U_DELETE(psql_fortune) + u_put_unalignedp64(ptr, U_MULTICHAR_CONSTANT64('<','/','t','d','>','<','/','t')); + u_put_unalignedp16(ptr+8, U_MULTICHAR_CONSTANT16('r','>')); + ptr += 8+2; + } - psql_fortune = U_NULLPTR; + u_put_unalignedp64(ptr, U_MULTICHAR_CONSTANT64('<','/','t','a','b','l','e','>')); + u_put_unalignedp64(ptr+8, U_MULTICHAR_CONSTANT64('<','/','b','o','d','y','>','<')); + u_put_unalignedp64(ptr+16, U_MULTICHAR_CONSTANT64('/','h','t','m','l','>','\0','\0')); + } - return; - } + static void doQuery(vPF handlerQuery) + { + U_TRACE(5, "Fortune::doQuery(%p)", handlerQuery) - U_NEW(UOrmStatement, pstmt_fortune, UOrmStatement(*psql_fortune, U_CONSTANT_TO_PARAM("SELECT id, message FROM Fortune"))); + initQuery(); + handlerQuery(); + endQuery(); + } - handlerFork(); + static void handlerInitSql() + { + U_TRACE_NO_PARAM(5, "Fortune::handlerInitSql()") - pstmt_fortune->into(uid, *pmessage); - } - } +# ifdef U_STATIC_ORM_DRIVER_PGSQL + U_INTERNAL_DUMP("UServer_Base::handler_db2 = %p", UServer_Base::handler_db2) + + if (UServer_Base::handler_db2 == U_NULLPTR) + { + U_NEW_WITHOUT_CHECK_MEMORY(UEventDB, UServer_Base::handler_db2, UEventDB); + } +# endif + } + + static void handlerFork() + { + U_TRACE_NO_PARAM(5, "Fortune::handlerFork()") + + U_NEW_STRING(pmessage, UString(101U)); + + U_NEW(UVector, pvfortune, UVector); + + Fortune* elem; + + for (uint32_t i = 0; i < 13; ++i) + { + U_NEW(Fortune, elem, Fortune(i+1)); + + pvfortune->push(elem); + } + } + + static void handlerForkSql() + { + U_TRACE_NO_PARAM(5, "Fortune::handlerForkSql()") + + if (psql_fortune == U_NULLPTR) + { + U_NEW(UOrmSession, psql_fortune, UOrmSession(U_CONSTANT_TO_PARAM("fortune"))); + + if (psql_fortune->isReady() == false) + { + U_WARNING("Fortune::handlerForkSql(): we cound't connect to db"); + + U_DELETE(psql_fortune) + + psql_fortune = U_NULLPTR; + + return; + } + + U_NEW(UOrmStatement, pstmt_fortune, UOrmStatement(*psql_fortune, U_CONSTANT_TO_PARAM("SELECT id, message FROM Fortune"))); + + handlerFork(); + + pstmt_fortune->into(uid, *pmessage); + +# ifdef U_STATIC_ORM_DRIVER_PGSQL + if (UOrmDriver::isPGSQL()) + { + conn = (PGconn*)(pdrv = (UOrmDriverPgSql*)psql_fortune->getDriver())->UOrmDriver::connection; + pstmt = (UPgSqlStatement*)pstmt_fortune->getStatement(); + + pstmt->prepareStatement(pdrv); + + ((UEventDB*)UServer_Base::handler_db2)->setConnection(conn); + } +# endif + } + } + +#ifdef DEBUG + static void handlerEnd() + { + U_TRACE_NO_PARAM(5, "Fortune::handlerEnd()") + + U_INTERNAL_ASSERT_POINTER(pmessage) + U_INTERNAL_ASSERT_POINTER(pvfortune) + + U_DELETE(pmessage) + U_DELETE(pvfortune) + } + + static void handlerEndSql() + { + U_TRACE_NO_PARAM(5, "Fortune::handlerEndSql()") + + if (pstmt_fortune) + { + handlerEnd(); + + U_DELETE(psql_fortune) + U_DELETE(pstmt_fortune) + + pstmt_fortune = U_NULLPTR; + } + } + + const char* dump(bool breset) const; +#endif private: - U_DISALLOW_ASSIGN(Fortune) + U_DISALLOW_ASSIGN(Fortune) }; #endif diff --git a/tests/examples/benchmark/FrameworkBenchmarks/ULib/src/fortune.usp b/tests/examples/benchmark/FrameworkBenchmarks/ULib/src/fortune.usp index d1ade24f..e5030e18 100644 --- a/tests/examples/benchmark/FrameworkBenchmarks/ULib/src/fortune.usp +++ b/tests/examples/benchmark/FrameworkBenchmarks/ULib/src/fortune.usp @@ -5,12 +5,6 @@ TechEmpower Web Framework Benchmarks diff --git a/tests/examples/benchmark/FrameworkBenchmarks/ULib/src/fortuneNoSql.h b/tests/examples/benchmark/FrameworkBenchmarks/ULib/src/fortuneNoSql.h index 79f14cfb..381301af 100644 --- a/tests/examples/benchmark/FrameworkBenchmarks/ULib/src/fortuneNoSql.h +++ b/tests/examples/benchmark/FrameworkBenchmarks/ULib/src/fortuneNoSql.h @@ -12,104 +12,136 @@ # include #endif -class FortuneNoSql { +class U_EXPORT FortuneNoSql { public: #ifdef USE_MONGODB - static UMongoDBClient* mc; + static UMongoDBClient* mc; #endif - static void handlerQueryMongoDB() - { - U_TRACE(5, "FortuneNoSql::handlerQueryMongoDB()") + static void handlerQueryMongoDB() + { + U_TRACE(5, "FortuneNoSql::handlerQueryMongoDB()") - U_INTERNAL_ASSERT_POINTER(Fortune::pmessage) + U_INTERNAL_ASSERT_POINTER(Fortune::pmessage) -# ifdef USE_MONGODB - (void) mc->findAll(); +# ifdef USE_MONGODB + (void) mc->findAll(); - for (uint32_t i = 0, n = mc->vitem.size(); i < n; ++i) - { - (void) U_JFIND(mc->vitem[i], "message", *Fortune::pmessage); + for (uint32_t i = 0, n = mc->vitem.size(); i < n; ++i) + { + (void) U_JFIND(mc->vitem[i], "message", *Fortune::pmessage); - Fortune::replace(i, i+1); + Fortune::replace(i, i+1); - Fortune::pmessage->clear(); - } -# endif - } + Fortune::pmessage->clear(); + } +# endif + } - static void handlerForkMongoDB() - { - U_TRACE_NO_PARAM(5, "FortuneNoSql::handlerForkMongoDB()") + static void handlerForkMongoDB() + { + U_TRACE_NO_PARAM(5, "FortuneNoSql::handlerForkMongoDB()") -# ifdef USE_MONGODB - if (mc == U_NULLPTR) - { - U_NEW(UMongoDBClient, mc, UMongoDBClient); +# ifdef USE_MONGODB + if (mc == U_NULLPTR) + { + U_NEW(UMongoDBClient, mc, UMongoDBClient); - if (mc->connect(U_NULLPTR, 0) == false) - { - U_WARNING("FortuneNoSql::handlerForkMongoDB(): connection failed"); + if (mc->connect(U_NULLPTR, 0) == false) + { + U_WARNING("FortuneNoSql::handlerForkMongoDB(): connection failed"); - U_DELETE(mc) + U_DELETE(mc) - mc = U_NULLPTR; + mc = U_NULLPTR; - return; - } + return; + } - if (mc->selectCollection("hello_world", "fortune") == false) - { - U_WARNING("FortuneNoSql::handlerForkMongoDB(): selectCollection() failed"); + if (mc->selectCollection("hello_world", "fortune") == false) + { + U_WARNING("FortuneNoSql::handlerForkMongoDB(): selectCollection() failed"); - U_DELETE(mc) + U_DELETE(mc) - mc = U_NULLPTR; + mc = U_NULLPTR; - return; - } + return; + } - Fortune::handlerFork(); - } -# endif - } + Fortune::handlerFork(); + } +# endif + } - static UREDISClient_Base* rc; + static UREDISClient_Base* rc; - static void handlerQueryREDIS() - { - U_TRACE(5, "FortuneNoSql::handlerQueryREDIS()") + static void handlerQueryREDIS() + { + U_TRACE(5, "FortuneNoSql::handlerQueryREDIS()") - (void) rc->lrange(U_CONSTANT_TO_PARAM("fortunes 0 -1")); + (void) rc->lrange(U_CONSTANT_TO_PARAM("fortunes 0 -1")); - for (uint32_t i = 0, n = rc->vitem.size(); i < n; ++i) Fortune::replace(i, rc->vitem[i]); - } + for (uint32_t i = 0, n = rc->vitem.size(); i < n; ++i) Fortune::replace(i, rc->vitem[i]); + } - static void handlerForkREDIS() - { - U_TRACE_NO_PARAM(5, "Fortune::handlerForkREDIS()") + static void handlerForkREDIS() + { + U_TRACE_NO_PARAM(5, "Fortune::handlerForkREDIS()") - if (rc == U_NULLPTR) - { - U_NEW(UREDISClient, rc, UREDISClient); + if (rc == U_NULLPTR) + { + U_NEW(UREDISClient, rc, UREDISClient); - if (rc->connect() == false) - { - U_WARNING("FortuneNoSql::handlerForkREDIS(): %V", rc->UClient_Base::getResponse().rep); + if (rc->connect() == false) + { + U_WARNING("FortuneNoSql::handlerForkREDIS(): %V", rc->UClient_Base::getResponse().rep); - U_DELETE(rc) + U_DELETE(rc) - rc = U_NULLPTR; + rc = U_NULLPTR; - return; - } + return; + } - Fortune::handlerFork(); - } - } + Fortune::handlerFork(); + } + } + +#ifdef DEBUG + static void handlerEndMongoDB() + { + U_TRACE_NO_PARAM(5, "FortuneNoSql::handlerEndMongoDB()") + +# ifdef USE_MONGODB + if (mc) + { + Fortune::handlerEnd(); + + U_DELETE(mc) + + mc = U_NULLPTR; + } +# endif + } + + static void handlerEndREDIS() + { + U_TRACE_NO_PARAM(5, "FortuneNoSql::handlerEndREDIS()") + + if (rc) + { + Fortune::handlerEnd(); + + U_DELETE(rc) + + rc = U_NULLPTR; + } + } +#endif private: - U_DISALLOW_ASSIGN(FortuneNoSql) + U_DISALLOW_ASSIGN(FortuneNoSql) }; #endif diff --git a/tests/examples/benchmark/FrameworkBenchmarks/ULib/src/json.usp b/tests/examples/benchmark/FrameworkBenchmarks/ULib/src/json.usp index 9aaf9268..5c2d6359 100644 --- a/tests/examples/benchmark/FrameworkBenchmarks/ULib/src/json.usp +++ b/tests/examples/benchmark/FrameworkBenchmarks/ULib/src/json.usp @@ -3,6 +3,7 @@ Test type 1: JSON serialization TechEmpower Web Framework Benchmarks --> diff --git a/tests/examples/benchmark/FrameworkBenchmarks/ULib/src/libFortune.cxx b/tests/examples/benchmark/FrameworkBenchmarks/ULib/src/libFortune.cxx index 3ce54fc9..f0ea32a4 100644 --- a/tests/examples/benchmark/FrameworkBenchmarks/ULib/src/libFortune.cxx +++ b/tests/examples/benchmark/FrameworkBenchmarks/ULib/src/libFortune.cxx @@ -2,8 +2,31 @@ #include "fortune.h" -uint32_t Fortune::uid; -UString* Fortune::pmessage; -UOrmSession* Fortune::psql_fortune; -UOrmStatement* Fortune::pstmt_fortune; +char* Fortune::pwbuffer; +uint32_t Fortune::uid; +UString* Fortune::pmessage; +UOrmSession* Fortune::psql_fortune; +UOrmStatement* Fortune::pstmt_fortune; UVector* Fortune::pvfortune; +#ifdef U_STATIC_ORM_DRIVER_PGSQL +PGconn* Fortune::conn; +UOrmDriverPgSql* Fortune::pdrv; +UPgSqlStatement* Fortune::pstmt; +#endif + +#ifdef DEBUG +const char* Fortune::dump(bool breset) const +{ + *UObjectIO::os << "id " << id << '\n' + << "message (UString " << (void*)&message << ')'; + + if (breset) + { + UObjectIO::output(); + + return UObjectIO::buffer_output; + } + + return U_NULLPTR; +} +#endif diff --git a/tests/examples/benchmark/FrameworkBenchmarks/ULib/src/libFortuneNoSql.cxx b/tests/examples/benchmark/FrameworkBenchmarks/ULib/src/libFortuneNoSql.cxx index b41f04a8..7b05a9c1 100644 --- a/tests/examples/benchmark/FrameworkBenchmarks/ULib/src/libFortuneNoSql.cxx +++ b/tests/examples/benchmark/FrameworkBenchmarks/ULib/src/libFortuneNoSql.cxx @@ -3,6 +3,6 @@ #include "fortuneNoSql.h" #ifdef USE_MONGODB -UMongoDBClient* FortuneNoSql::mc; +UMongoDBClient* FortuneNoSql::mc; #endif UREDISClient_Base* FortuneNoSql::rc; diff --git a/tests/examples/benchmark/FrameworkBenchmarks/ULib/src/libWorld.cxx b/tests/examples/benchmark/FrameworkBenchmarks/ULib/src/libWorld.cxx index 9e03d999..bd882174 100644 --- a/tests/examples/benchmark/FrameworkBenchmarks/ULib/src/libWorld.cxx +++ b/tests/examples/benchmark/FrameworkBenchmarks/ULib/src/libWorld.cxx @@ -2,16 +2,34 @@ #include "world.h" -char World::wbuffer[18000]; -char* World::pwbuffer; -World* World::pworld_query; -uint32_t World::rnum; -uint32_t World::rnumber[500]; -UOrmSession* World::psql_query; -UOrmStatement* World::pstmt_query; +char World::wbuffer[18000]; +char* World::ptr; +char* World::pwbuffer; +World* World::pworld_query; +uint32_t World::rnum; +uint32_t World::rnumber[501]; +UOrmSession* World::psql_query; +UOrmStatement* World::pstmt_query; #ifdef U_STATIC_ORM_DRIVER_PGSQL -char World::num2str[sizeof(unsigned int)]; -PGconn* World::conn; +char World::num2str[sizeof(unsigned int)]; +PGconn* World::conn; UOrmDriverPgSql* World::pdrv; UPgSqlStatement* World::pstmt; #endif + +#ifdef DEBUG +const char* World::dump(bool breset) const +{ + *UObjectIO::os << "id " << id << '\n' + << "randomNumber " << randomNumber; + + if (breset) + { + UObjectIO::output(); + + return UObjectIO::buffer_output; + } + + return U_NULLPTR; +} +#endif diff --git a/tests/examples/benchmark/FrameworkBenchmarks/ULib/src/libWorldNoSql.cxx b/tests/examples/benchmark/FrameworkBenchmarks/ULib/src/libWorldNoSql.cxx index 66466550..95b6895f 100644 --- a/tests/examples/benchmark/FrameworkBenchmarks/ULib/src/libWorldNoSql.cxx +++ b/tests/examples/benchmark/FrameworkBenchmarks/ULib/src/libWorldNoSql.cxx @@ -3,14 +3,14 @@ #include "worldNoSql.h" #ifdef USE_MONGODB -bson_t* WorldNoSql::query; -UMongoDBClient* WorldNoSql::mc; +bson_t* WorldNoSql::query; +UMongoDBClient* WorldNoSql::mc; #endif -char WorldNoSql::rc_buffer[128]; -char WorldNoSql::es_buffer1[128]; -char WorldNoSql::es_buffer2[128]; -char* WorldNoSql::pbuffer1; -char* WorldNoSql::pbuffer2; -UString* WorldNoSql::str_rnumber; -UREDISClient_Base* WorldNoSql::rc; +char WorldNoSql::rc_buffer[128]; +char WorldNoSql::es_buffer1[128]; +char WorldNoSql::es_buffer2[128]; +char* WorldNoSql::pbuffer1; +char* WorldNoSql::pbuffer2; +UString* WorldNoSql::str_rnumber; +UREDISClient_Base* WorldNoSql::rc; UElasticSearchClient* WorldNoSql::es; diff --git a/tests/examples/benchmark/FrameworkBenchmarks/ULib/src/plaintext.usp b/tests/examples/benchmark/FrameworkBenchmarks/ULib/src/plaintext.usp index 8ab686ea..ba06d3f3 100644 --- a/tests/examples/benchmark/FrameworkBenchmarks/ULib/src/plaintext.usp +++ b/tests/examples/benchmark/FrameworkBenchmarks/ULib/src/plaintext.usp @@ -1 +1,18 @@ -Hello, World! + + diff --git a/tests/examples/benchmark/FrameworkBenchmarks/ULib/src/query.usp b/tests/examples/benchmark/FrameworkBenchmarks/ULib/src/query.usp index 98d56313..052774de 100644 --- a/tests/examples/benchmark/FrameworkBenchmarks/ULib/src/query.usp +++ b/tests/examples/benchmark/FrameworkBenchmarks/ULib/src/query.usp @@ -5,6 +5,7 @@ TechEmpower Web Framework Benchmarks