1#!/usr/bin/env python
2# Copyright (c) 2011 The Chromium Authors. All rights reserved.
3# Use of this source code is governed by a BSD-style license that can be
4# found in the LICENSE file.
5
6"""Takes an input JSON, and filters out all system call events that
7took less than 0.2ms.
8
9This helps trim down the JSON data to only the most interesting / time critical
10events.
11"""
12
13import sys
14import re
15
16
17def parseEvents(z):
18  print 'parseEvents(['
19  for e in z:
20    if e.has_key('ms') and e.has_key('done'):
21      dur = e['done'] - e['ms']
22      if dur < 0.2:
23        continue
24    # Ugly regex to remove the L suffix on large python numbers.
25    print '%s,' % re.sub('([0-9])L\\b', '\\1', str(e))
26  print '])'
27
28
29def main():
30  execfile(sys.argv[1])
31
32
33if __name__ == '__main__':
34  main()
35