From f73dae828e4720cf237043d3af9565099d75481d Mon Sep 17 00:00:00 2001
From: "Michael \"Z\" Goddard" <mzgoddard@gmail.com>
Date: Thu, 9 Nov 2017 17:28:40 -0500
Subject: [PATCH] Add enableProfiling and disableProfiling to Runtime

---
 src/engine/runtime.js | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/src/engine/runtime.js b/src/engine/runtime.js
index 3ba173718..39be44db8 100644
--- a/src/engine/runtime.js
+++ b/src/engine/runtime.js
@@ -7,6 +7,7 @@ const Blocks = require('./blocks');
 const BlockType = require('../extension-support/block-type');
 const Sequencer = require('./sequencer');
 const Thread = require('./thread');
+const Profiler = require('./profiler');
 
 // Virtual I/O devices.
 const Clock = require('../io/clock');
@@ -1467,6 +1468,24 @@ class Runtime extends EventEmitter {
             this._step();
         }, interval);
     }
+
+    /**
+     * Turn on profiling.
+     * @param {Profiler/FrameCallback} onFrame A callback handle passed a
+     * profiling frame when the profiler reports its collected data.
+     */
+    enableProfiling (onFrame) {
+        if (Profiler.available()) {
+            this.profiler = new Profiler(onFrame);
+        }
+    }
+
+    /**
+     * Turn off profiling.
+     */
+    disableProfiling () {
+        this.profiler = null;
+    }
 }
 
 /**