commit to save files

Change-Id: I4736070be91efd1d38f5a55e46e801c16d39336b
diff --git a/bin/run_benchmarks/BUILD.gn b/bin/run_benchmarks/BUILD.gn
new file mode 100644
index 0000000..41a0912
--- /dev/null
+++ b/bin/run_benchmarks/BUILD.gn
@@ -0,0 +1,32 @@
+# Copyright 2018 The Fuchsia Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import("//build/package.gni")
+
+copy("copy_run_benchmarks") {
+  sources = [
+    "run_benchmarks.sh",
+  ]
+
+  outputs = [
+    "$root_out_dir/run_benchmarks",
+  ]
+}
+
+package("run_benchmarks") {
+  testonly = true
+  deprecated_system_image = true
+
+  deps = [
+    ":copy_run_benchmarks",
+  ]
+
+  tests = [ {
+        name = "run_benchmarks"
+      }, {
+        name = "run_benchmarks"
+        dest = "perf/run_benchmarks"
+      } ]
+}
+
diff --git a/bin/run_benchmarks/run_benchmarks.sh b/bin/run_benchmarks/run_benchmarks.sh
new file mode 100644
index 0000000..0418862
--- /dev/null
+++ b/bin/run_benchmarks/run_benchmarks.sh
@@ -0,0 +1,30 @@
+#!/bin/bash
+
+set -e
+
+OUTPUT_DIR="${1}"
+
+TSPEC_FILES_DIR="/system/data/ledger/benchmark/*"
+if ! [ -d ${TSPEC_FILES_DIR} ]; then
+    echo "${TSPEC_FILES_DIR} does not exist. tracing tests will not run"
+    exit 1;
+fi
+
+# Run all tracing tests.
+for tspec_file in $TSPEC_FILES_DIR; do
+    # Use the name of the tspec file as the unique test ID. Strip away the
+    # ".tspec" file suffix.
+    benchmark_id=$(basename $tspec_file .tspec)
+
+    # Make sure the name is not empty.
+    if [ -z ${benchmark_id} ]; then
+      echo "skipping tspec file with invalid name $tspec_file".
+      continue
+    fi
+
+    # Run the tracing test.
+    trace record --spec-file=$tspec_file \
+                 --benchmark-results-file="${OUTPUT_DIR}/${benchmark_id}"
+done
+
+
diff --git a/packages/benchmarks/all b/packages/benchmarks/all
index 3e0b890..b101237 100644
--- a/packages/benchmarks/all
+++ b/packages/benchmarks/all
@@ -1,4 +1,8 @@
 {
+    "packages": [
+        "peridot/bin/run_benchmarks"
+    ],
+
     "imports": [
         "peridot/packages/benchmarks/modular"
     ]