Home | History | Annotate | Download | only in bin
      1 #!/usr/bin/env python
      2 # Copyright 2016 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 import os
      6 import sys
      7 import json
      8 import ntpath
      9 
     10 
     11 OUT_DIR = 'v8_callstats_dump'
     12 
     13 URL_MAP = dict()
     14 
     15 URL_MAP['http___edition_cnn_com10.html'] = 'cnn.com'
     16 URL_MAP['http___hi_wikipedia_org_wiki__E0_A4_AE_E0_A5_81_E0_A4_96_E0_A4_AA_E0_A5_83_E0_A4_B7_E0_A5_8D_E0_A4_A06.html'] = 'wikipedia.org'
     17 URL_MAP['http___inbox_google_com23.html'] = 'inbox.google.com'
     18 URL_MAP['http___maps_google_co_jp_maps_search_restaurant_tokyo24.html'] = 'maps.google.co.jp'
     19 URL_MAP['http___meta_discourse_org21.html'] = 'discourse.org'
     20 URL_MAP['http___reddit_musicplayer_io22.html'] = 'reddit.musicplayer.io'
     21 URL_MAP['https___www_facebook_com_shakira2.html'] = 'facebook.com'
     22 URL_MAP['https___www_google_de_search_q_v80.html'] = 'google.de'
     23 URL_MAP['https___www_linkedin_com_m_13.html'] = 'linkedin.com'
     24 URL_MAP['https___www_youtube_com1.html'] = 'youtube.com'
     25 URL_MAP['http___weibo_com18.html'] = 'weibo.com'
     26 URL_MAP['http___world_taobao_com11.html'] = 'taobao.com'
     27 URL_MAP['http___www_amazon_com_s__field_keywords_v85.html'] = 'amazon.com'
     28 URL_MAP['http___www_baidu_com_s_wd_v83.html'] = 'baidu.com'
     29 URL_MAP['http___www_bing_com_search_q_v8_engine15.html'] = 'bing.com'
     30 URL_MAP['http___www_ebay_fr_sch_i_html__nkw_v89.html'] = 'ebay.fr'
     31 URL_MAP['http___www_instagram_com_archdigest12.html'] = 'instagram.com'
     32 URL_MAP['http___www_msn_com_ar_ae14.html'] = 'msn.com'
     33 URL_MAP['http___www_pinterest_com_categories_popular16.html'] = 'pinterest.com'
     34 URL_MAP['http___www_qq_com7.html'] = 'qq.com'
     35 URL_MAP['http___www_reddit_com8.html'] = 'reddit.com'
     36 URL_MAP['http___www_sina_com_cn17.html'] = 'sina.com.cn'
     37 URL_MAP['http___www_wikiwand_com_en_hill20.html'] = 'wikiwand.com'
     38 URL_MAP['http___www_yahoo_co_jp4.html'] = 'yahoo.co.jp'
     39 URL_MAP['http___yandex_ru_search__text_v819.html'] = 'yandex.ru'
     40 
     41 
     42 def extractFilename(path):
     43     head, tail = ntpath.split(path)
     44     name = tail or ntpath.basename(head)
     45     if name in URL_MAP:
     46       return URL_MAP[name]
     47     return name
     48 
     49 
     50 def writeDump(name, value):
     51   dump_file = open(OUT_DIR + '/' + extractFilename(name) + '.txt', 'w+')
     52   runtime_call = value['pairs']
     53   for name in runtime_call:
     54     dump_file.write(name + '\t' + str(runtime_call[name]['time']) + '\tX\t' + str(runtime_call[name]['count']) + '\n')
     55   dump_file.close()
     56 
     57 if __name__ == '__main__':
     58   with open(sys.argv[1]) as data_file:
     59     data = json.load(data_file)
     60 
     61   if not os.path.exists(OUT_DIR):
     62     os.makedirs(OUT_DIR)
     63 
     64   for entry in data:
     65     writeDump(entry, data[entry])
     66   sys.exit(0)
     67