diff options
-rw-r--r-- | .github/workflows/build.yml | 27 | ||||
-rw-r--r-- | configure.ac | 3 | ||||
-rwxr-xr-x | tests/do.sh.in | 14 |
3 files changed, 42 insertions, 2 deletions
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a720f440c..a1d8aa1c0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -91,7 +91,7 @@ jobs: sudo apt-get install autoconf automake libtool pkg-config gettext flex bison doxygen - name: Configure nDPI library run: | - ./autogen.sh --with-only-libndpi + ./autogen.sh --with-only-libndpi --enable-option-checking=fatal - name: Generate Documentation run: | pip install --upgrade pip @@ -105,6 +105,31 @@ jobs: path: doc/_build/ndpi-documentation-upload retention-days: 7 + performance: + name: Performance (ubuntu-latest) + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Install Ubuntu Prerequisites + run: | + sudo apt-get update + sudo apt-get install autoconf automake libtool pkg-config gettext flex bison libpcap-dev + sudo apt-get install golang-1.16-go libgoogle-perftools-dev + env GO111MODULE=on go install github.com/google/pprof@latest + sudo ln -s ${HOME}/go/bin/pprof /usr/bin/pprof + pprof -h + - name: Configure nDPI library + run: | + ./autogen.sh --enable-gprof --enable-option-checking=fatal ${{ matrix.gcrypt }} ${{ matrix.msan }} ${{ matrix.pcre }} ${{ matrix.maxminddb }} + - name: Build nDPI library + run: | + make + - name: Performance Profiling + run: | + env LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libprofiler.so ./tests/do.sh + test-scripts: name: Test Utils (ubuntu-latest) runs-on: ubuntu-latest diff --git a/configure.ac b/configure.ac index 8272b6ba0..b9c4259b9 100644 --- a/configure.ac +++ b/configure.ac @@ -277,6 +277,7 @@ return 0; ]) AM_CONDITIONAL([HAS_FUZZLDFLAGS], [test "x$has_sanitizefuzzer" = "xyes"]) +GPROF_ENABLED=0 AS_IF([test "x$enable_gprof" = "xyes"], [ PKG_CHECK_MODULES([PROFILER], [libprofiler],,[ AC_MSG_ERROR([libprofiler not available. Required for profiling support.]) @@ -284,6 +285,7 @@ AS_IF([test "x$enable_gprof" = "xyes"], [ PKG_CHECK_MODULES([TCMALLOC], [libtcmalloc],,[ AC_MSG_ERROR([libtcmalloc not available. Required for profiling support.]) ]) + GPROF_ENABLED=1 GPROF_LIBS="${pkg_cv_PROFILER_LIBS} ${pkg_cv_TCMALLOC_LIBS}" GPROF_CFLAGS="${pkg_cv_PROFILER_CFLAGS} ${pkg_cv_TCMALLOC_CFLAGS}" ]) @@ -356,6 +358,7 @@ AC_SUBST(JSONC_CFLAGS) AC_SUBST(JSONC_LIBS) AC_SUBST(GPROF_CFLAGS) AC_SUBST(GPROF_LIBS) +AC_SUBST(GPROF_ENABLED) AC_SUBST(USE_HOST_LIBGCRYPT) AC_SUBST(PCRE_ENABLED) AC_SUBST(HANDLE_TLS_SIGS) diff --git a/tests/do.sh.in b/tests/do.sh.in index ba16045a0..3d9bfeaca 100755 --- a/tests/do.sh.in +++ b/tests/do.sh.in @@ -20,6 +20,7 @@ CMD_WDIFF="$(which wdiff)" CMD_COLORDIFF="$(which colordiff)" EXE_SUFFIX=@EXE_SUFFIX@ +GPROF_ENABLED=@GPROF_ENABLED@ PCRE_ENABLED=@PCRE_ENABLED@ PCRE_PCAPS="WebattackRCE.pcap" GCRYPT_PCAPS="gquic.pcap quic-23.pcap quic-24.pcap quic-27.pcap quic-28.pcap quic-29.pcap quic-mvfst-22.pcap quic-mvfst-27.pcapng quic-mvfst-exp.pcap quic_q50.pcap quic_t50.pcap quic_t51.pcap quic_0RTT.pcap quic_interop_V.pcapng quic-33.pcapng doq.pcapng doq_adguard.pcapng dlt_ppp.pcap os_detected.pcapng quic_frags_ch_out_of_order_same_packet_craziness.pcapng quic_frags_ch_in_multiple_packets.pcapng quic-v2-00.pcapng" @@ -34,6 +35,12 @@ if [ ! -x "../example/ndpiReader${EXE_SUFFIX}" ]; then exit 1 fi +if [ ${GPROF_ENABLED} -eq 1 ]; then + GPROF="$(which pprof)" +else + GPROF=false +fi + fuzzy_testing() { if [ -f ../fuzz/fuzz_ndpi_reader ]; then ../fuzz/fuzz_ndpi_reader -max_total_time="${MAX_TOTAL_TIME:-592}" -print_pcs=1 -workers="${FUZZY_WORKERS:-0}" -jobs="${FUZZY_JOBS:-0}" pcap/ @@ -74,7 +81,7 @@ check_results() { if [ -f result/$f.out ]; then CMD="$READER -q -K JSON -k /dev/null -t -i pcap/$f -w /tmp/reader.out -v 2" - $CMD + CPUPROFILE=result/$f.cprof HEAPPROFILE=result/$f $CMD CMD_RET=$? if [ $CMD_RET -eq 0 ]; then NUM_DIFF=`${CMD_DIFF} result/$f.out /tmp/reader.out | wc -l` @@ -99,6 +106,11 @@ check_results() { /bin/rm -f /tmp/reader.out fi done + + if [ ${GPROF_ENABLED} -eq 1 ]; then + ${GPROF} -top -nodecount 100 -nodefraction 0 -show '^(ndpi)' ../example/ndpiReader${EXE_SUFFIX} ./result/*.cprof || RC=$(( RC + 1 )) + ${GPROF} -top -nodecount 100 -nodefraction 0 -show '^(ndpi)' ../example/ndpiReader${EXE_SUFFIX} ./result/*.heap || RC=$(( RC + 1 )) + fi } if [ $FUZZY_TESTING_ENABLED -eq 1 ]; then |