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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « test/perf/perf.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/usr/bin/env dart
2 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
3 // for details. All rights reserved. Use of this source code is governed by a
4 // BSD-style license that can be found in the LICENSE file.
5
6 /**
7 * A simple script that updates a target json file with the new values from
8 * another json file.
9 */
10 library test.perf.update_json;
11
12 import 'dart:io';
13 import 'dart:json';
14 import 'dart:math' as math;
15
16 main() {
17 var args = new Options().arguments;
18 if (args.length < 2) {
19 print('update_json.dart: A simple script that updates a target json file '
20 'with the new values from another json file. ');
21 print('usage: update.dart from.json to.json');
22 exit(1);
23 }
24
25 var path1 = args[0];
26 var path2 = args[1];
27 var file1 = new File(path1).readAsStringSync();
28 var file2 = new File(path2).readAsStringSync();
29
30 var results = [];
31 var map1 = JSON.parse(file1);
32 var map2 = JSON.parse(file2);
33
34 for (var key in map1.keys) {
35 if (map1[key] != null) {
36 map2[key] = map1[key];
37 }
38 }
39
40 print('updating $path2...');
41 _writeFile(path2, JSON.stringify(map2));
42 }
43
44 Future _writeFile(String path, String text) {
45 return new File(path).open(FileMode.WRITE)
46 .chain((file) => file.writeString(text))
47 .chain((file) => file.close());
48 }
OLDNEW
« 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