Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / native_client / tests / spec2k / emit_perf_log.sh
1 #!/bin/bash
2
3 # Copyright (c) 2011 The Native Client Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file.
6
7 set -o nounset
8 set -o errexit
9
10 #@ LogRealTime <time_file> <graph_label> <bench> <compiler_setup>
11 #@   Take wall time data from <time_file>, and log it for the Chrome perf bots.
12 #@   <time_file> should be a single line where column 1 and 2 are user/sys.
13 LogRealTime() {
14   local time_file=$1
15   local graph_label=$2
16   local bench=$3
17   local setup=$4
18   # Generate a list of times "[x,y,z]". The chromium perf log parser
19   # will know to average this list of times.
20   local times="[$(awk '{print $3}' ${time_file} | \
21                    tr '\n' ',' | sed 's/,$//')]"
22   LogPerf ${graph_label} ${bench} ${setup} "${times}" "seconds"
23 }
24
25 #@ LogGzippedSize <file_to_zip> <graph_label> <bench> <compiler_setup>
26 #@   Measure and log size of gzipped executable/bc files/etc.
27 LogGzippedSize() {
28   local file_to_zip=$1
29   local graph_label=$2
30   local bench=$3
31   local setup=$4
32   local tempsize=`gzip ${file_to_zip} -c | wc -c`
33   LogPerf ${graph_label} ${bench} ${setup} ${tempsize} "bytes"
34 }
35
36 #@ Emit a chrome perf log datapoint
37 #@  $1 :: graph_type
38 #@  $2 :: bench_name
39 #@  $3 :: compiler setup
40 #@  $4 :: measurement value
41 #@  $5 :: unit
42 LogPerf() {
43   echo "RESULT $1_$2: $3= $4 $5"
44 }
45
46 ######################################################################
47 # Main
48 ######################################################################
49
50 # Print the usage message to stdout.
51 Usage() {
52   egrep "^#@" $0 | cut --bytes=3-
53 }
54
55 [ $# = 0 ] && set -- help  # Avoid reference to undefined $1.
56
57 if [ "$(type -t $1)" != "function" ]; then
58   Usage
59   echo "ERROR: unknown mode '$1'." >&2
60   exit 1
61 fi
62
63 eval "$@"