Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1191)

Unified Diff: tools/node-polyfill.js

Issue 1179173009: Add support for running the profiler output processing scripts with node. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: buffered readline polyfill Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/node-mac-tick-processor ('k') | tools/node-windows-tick-processor.bat » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/node-polyfill.js
diff --git a/test/mjsunit/regress/regress-3976.js b/tools/node-polyfill.js
similarity index 61%
copy from test/mjsunit/regress/regress-3976.js
copy to tools/node-polyfill.js
index efa3ac03bc05a5b1018eb1bdd0db761154f2b664..a82b6370d0381615af6c3cee21314d43740844e7 100644
--- a/test/mjsunit/regress/regress-3976.js
+++ b/tools/node-polyfill.js
@@ -25,56 +25,40 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-// Flags: --max-old-space-size=60 --check-handle-count
-
-table = [];
-
-for (var i = 0; i < 32; i++) {
- table[i] = String.fromCharCode(i + 0x410);
-}
-
-
-var random = (function() {
- var seed = 10;
- return function() {
- seed = (seed * 1009) % 8831;
- return seed;
- };
-})();
-
-
-function key(length) {
- var s = "";
- for (var i = 0; i < length; i++) {
- s += table[random() % 32];
+// Node polyfill
+var os = os || {
+ system: function(name, args) {
+ return require('child_process').execFileSync(
+ name, args, {encoding: 'utf8'}).toString();
}
- return '"' + s + '"';
-}
-
-
-function value() {
- return '[{' + '"field1" : ' + random() + ', "field2" : ' + random() + '}]';
-}
-
-
-function generate(n) {
- var s = '{';
- for (var i = 0; i < n; i++) {
- if (i > 0) s += ', ';
- s += key(random() % 10 + 7);
- s += ':';
- s += value();
+};
+var print = print || console.log.bind(console);
+var read = read || function(fileName) {
+ return require('fs').readFileSync(fileName, 'utf8');
+};
+if (typeof process !== "undefined" && process.argv) {
+ print("Polyfilling arguments");
+ arguments = process.argv.slice(2);
+
+ // Polyfill "readline()".
+ var fs = require('fs');
+ var fd = fs.openSync(arguments[0], 'rs');
+ var buf = new Buffer(4096);
+ var line = "";
+ var readline = function() {
+ while (true) {
+ var line_break = line.indexOf('\n');
+ if (line_break !== -1) {
+ var res = line.slice(0, line_break);
+ line = line.slice(line_break + 1);
+ return res;
+ }
+ var bytes = fs.readSync(fd, buf, 0, buf.length);
+ line += buf.toString('utf8', 0, bytes);
+ if (line.length === 0) {
+ return false;
+ }
+ }
}
- s += '}';
- return s;
-}
-
-print("generating");
-
-var str = generate(50000);
-
-print("parsing " + str.length);
-JSON.parse(str);
-
-print("done");
+}
« no previous file with comments | « tools/node-mac-tick-processor ('k') | tools/node-windows-tick-processor.bat » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698