File: cpu-bench-with-trace

package info (click to toggle)
bro-aux 0.42-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, buster, sid, trixie
  • size: 1,104 kB
  • sloc: sh: 999; ansic: 943; ruby: 71; makefile: 68; perl: 35; cpp: 26
file content (35 lines) | stat: -rwxr-xr-x 876 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#! /usr/bin/env bash
#
# This runs a number of Bro configurations on trace $2. It
# starts with the bare config and then
# kept adding the scripts load from init-default.bro and local.bro one
# by one, measuring user time for each run (i.e., the measurements are
# cumulative).

if [ "$2" == "" ]; then
    echo "usage: `basename $0` <brodir> <trace>"
    exit 1
fi

bro=$1
trace=$2
tmp=/tmp/bench.$$.bro

export BROPATH=`$bro/build/bro-path-dev`

cat </dev/null >$tmp

cat $bro/scripts/base/init-default.bro $bro/scripts/site/local.bro | grep '^ *@load' | while read line; do
    echo $line >>$tmp
    script=`echo $line | awk '{print $2}' | sed 's#/#.#g'`
    output="bench.output.$script.log"

    ( time -p $bro/build/src/bro -b -r $trace $tmp )  >$output 2>&1
    user=`cat $output | grep user | awk '{print $2}'`
    printf "%40s %s\n" $script $user
done

rm -f $tmp