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

Unified Diff: test/perf/update_json.dart

Issue 11683002: Setting up benchmarks and perf utilities (Closed) Base URL: git@github.com:dart-lang/web-ui.git@master
Patch Set: john comments Created 7 years, 11 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 | « test/perf/perf.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/perf/update_json.dart
diff --git a/test/perf/update_json.dart b/test/perf/update_json.dart
new file mode 100755
index 0000000000000000000000000000000000000000..ca5becc318e2f2b74a8ad1dc028ef663c9af454b
--- /dev/null
+++ b/test/perf/update_json.dart
@@ -0,0 +1,48 @@
+#!/usr/bin/env dart
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+/**
+ * A simple script that updates a target json file with the new values from
+ * another json file.
+ */
+library test.perf.update_json;
+
+import 'dart:io';
+import 'dart:json';
+import 'dart:math' as math;
+
+main() {
+ var args = new Options().arguments;
+ if (args.length < 2) {
+ print('update_json.dart: A simple script that updates a target json file '
+ 'with the new values from another json file. ');
+ print('usage: update.dart from.json to.json');
+ exit(1);
+ }
+
+ var path1 = args[0];
+ var path2 = args[1];
+ var file1 = new File(path1).readAsStringSync();
+ var file2 = new File(path2).readAsStringSync();
+
+ var results = [];
+ var map1 = JSON.parse(file1);
+ var map2 = JSON.parse(file2);
+
+ for (var key in map1.keys) {
+ if (map1[key] != null) {
+ map2[key] = map1[key];
+ }
+ }
+
+ print('updating $path2...');
+ _writeFile(path2, JSON.stringify(map2));
+}
+
+Future _writeFile(String path, String text) {
+ return new File(path).open(FileMode.WRITE)
+ .chain((file) => file.writeString(text))
+ .chain((file) => file.close());
+}
« no previous file with comments | « test/perf/perf.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698