3 # find the name of the log file to process, it must not start with a dash.
7 if ! expr "X${arg}" : "^X-" > /dev/null; then
12 tools_path=`cd $(dirname "$0");pwd`
13 if [ ! "$D8_PATH" ]; then
15 if [ -x "$d8_public" ]; then D8_PATH=$(dirname "$d8_public"); fi
17 [ -n "$D8_PATH" ] || D8_PATH=$tools_path/..
20 if [ ! -x "$d8_exec" ]; then
21 D8_PATH=`pwd`/out/native
25 if [ ! -x "$d8_exec" ]; then
26 d8_exec=`grep -m 1 -o '".*/d8"' $log_file | sed 's/"//g'`
29 if [ ! -x "$d8_exec" ]; then
30 echo "d8 shell not found in $D8_PATH"
31 echo "To build, execute 'make native' from the V8 directory"
35 if [[ "$@" != *--distortion* ]]; then
36 # Try to find out how much the instrumentation overhead is.
37 calibration_log=calibration.log
38 calibration_script="for (var i = 0; i < 1000000; i++) print();"
40 $d8_exec --nocrankshaft --prof --logfile $calibration_log \
41 --log-timer-events -e "$calibration_script" > /dev/null
42 t_1_start=`grep "timer-event-start,\"V8.Execute\"" $calibration_log \
43 | tail -n1 | awk -F, '{print $3}'`
44 t_1_end=`grep "timer-event-end,\"V8.Execute\"" $calibration_log \
45 | tail -n1 | awk -F, '{print $3}'`
46 n_1=`grep "timer-event\|tick" $calibration_log | wc -l`
48 $d8_exec --nocrankshaft --prof --logfile $calibration_log \
49 --log-internal-timer-events -e "$calibration_script" > /dev/null
50 t_2_start=`grep "timer-event-start,\"V8.Execute\"" $calibration_log \
51 | tail -n1 | awk -F, '{print $3}'`
52 t_2_end=`grep "timer-event-end,\"V8.Execute\"" $calibration_log \
53 | tail -n1 | awk -F, '{print $3}'`
54 n_2=`grep "timer-event\|tick" $calibration_log | wc -l`
58 # Overhead in picoseconds.
60 options+=`echo "1000*(($t_1_end - $t_1_start) - ($t_2_end - $t_2_start)) \
61 / ($n_1 - $n_2)" | bc`
66 $d8_exec $tools_path/csvparser.js $tools_path/splaytree.js \
67 $tools_path/codemap.js $tools_path/profile.js $tools_path/profile_view.js \
68 $tools_path/logreader.js $tools_path/tickprocessor.js \
69 $tools_path/profviz/composer.js $tools_path/profviz/stdio.js \
70 -- $@ $options 2>/dev/null > timer-events.plot
73 if [[ $success != 0 ]] ; then
76 cat timer-events.plot | gnuplot > timer-events.png
79 rm -f timer-events.plot