diff --git a/src/analyze_stats.py b/src/analyze_stats.py new file mode 100755 index 0000000..e164366 --- /dev/null +++ b/src/analyze_stats.py @@ -0,0 +1,46 @@ +#!/usr/bin/env python3 + +import lib_common as mylib + +pp = ['flurry.com', 'facebook.com', 'admob.com', 'apple.com', 'tapjoyads.com', + 'crashlytics.com', 'ioam.de', 'amazonaws.com', 'chartboost.com', + 'googleadservices.com', + 'app-measurement.com', 'doubleclick.net', 'adjust.com', 'appsflyer.com' + ] +study = ["com.amazon.AmazonDE", "com.innersloth.amongus", "ca.gc.hcsc.canada.covid19", "com.instructure.icanvas", "mobi.gameguru.fruitsurgeon", "com.google.GoogleMobile", "com.google.chrome.ios", "com.google.Classroom", "com.burbn.instagram", "com.mcdonalds.mobileapp", "com.microsoft.skype.teams", "com.netflix.Netflix", "com.yourcompany.PPClient", "com.randonautica.app", "com.toyopagroup.picaboo", "com.casual.stairwaytoheaven", "com.tmobile.nameid", "com.burbn.threads", "com.zhiliaoapp.musically", "com.triller.projectx", "com.atebits.Tweetie2", "com.ubercab.UberEats", "net.whatsapp.WhatsApp", "com.google.ios.youtube", "com.zello.client.main", + "com.apm2studio.runawaychallenge", "com.adidas.app", "com.booking.BookingApp", "com.braindom", "es.aeat.pin24h", "de.rki.coronawarnapp", "com.Atinon.PassOver", "com.greeneking.orderandpay", "com.ingka.ikea.app", "it.ministerodellasalute.immuni", "it.pagopa.app.io", "fr.izly.izlyiphone", "lagamerie.mmv", "au.com.menulog.m", "com.apalonapps.radarfree", "it.poste.postebuy2", "com.neocortext.doublicatapp", "com.Celltop.SpiralRoll", "com.spotify.client", "com.qsdhbdft.stackblocks", "com.redforcegames.stack.colors", "ph.telegra.Telegraph", "com.eightsec.TriviaIO", "com.watched.play", "it.wind.mywind", + "com.alipay.iphoneclient", "jp.go.mhlw.covid19radar", "au.gov.health.covidsafe", "com.AnkaStudios.DriveThru3D", "ru.mail.mail", "com.phone.lock", "com.magictouch.xfollowers", "video.like", "jp.naver.line", "com.cg.moneybuster", "com.tencent.mqq", "zzkko.com.ZZKKO", "com.viber", "com.vk.vkclient", "com.waze.iphone", "com.tencent.xin", "icacacat.wobble.man.upstairs", "ru.avito.app", "ru.city-mobil.taxi", "com.yueyou.cyreader", "cn.gov.tax.its", "jp.jmty.Jmty", "com.siwuai.duapp", "com.huaxiaozhu.rider", "com.autonavi.amap"] +ret = {x: 0 for x in pp} +app_count = 0 +log_count = 0 +rec_count = [0, 0] +rec_total = [0, 0] + +for bid in mylib.appids_in_out(['*']): + app_count += 1 + for fname, json in mylib.enum_jsons(bid): + # if json['duration'] > 40: + i = 0 if bid in study else 1 + rec_count[i] += 1 + rec_total[i] += json['duration'] + for dom, logs in json['logs'].items(): + par = mylib.parent_domain(dom) + l = len(logs) + if par in pp: + ret[par] += l + log_count += l + +print('Domain: Percent of requests') +for k, x in ret.items(): + def in_pct(u): + return round(u * 10000) / 100 + print(f' {k}: {in_pct(x / log_count)}%') +print('') + +print('Avg rec time') +print(f' study {rec_total[0] / rec_count[0]} sec') +print(f' not study {rec_total[1] / rec_count[1]} sec') +print('') + +print(f'Apps: {app_count}, Recordings: {sum(rec_count)}, Logs: {log_count}') +print('') diff --git a/src/analyze_timeit.py b/src/analyze_timeit.py new file mode 100755 index 0000000..7b7db0c --- /dev/null +++ b/src/analyze_timeit.py @@ -0,0 +1,99 @@ +#!/usr/bin/env python3 + +import os +import sys +import timeit +import matplotlib +import matplotlib.pyplot as plt +matplotlib.use('Agg') # disable interactive mode + + +def split_arr(arr): + arr.sort(key=lambda x: -x[1]) + ret = [] + while len(arr) > 0: + ret.append(arr[0]) + del(arr[0]) + if len(arr) > 0: + ret.append(arr[-1]) + del(arr[-1]) + return [x[0] for x in ret], [x[1] for x in ret] + + +def gen_graph(arr, outfile): + keys, vals = split_arr(arr) + pie1, _ = plt.pie(vals, labels=keys, colors=['#AAA', '#444'], normalize=True) + plt.setp(pie1, width=0.5) + plt.subplots_adjust(left=0, right=1, top=0.7, bottom=0.3) + plt.savefig(outfile, bbox_inches='tight', pad_inches=0, transparent=True) + plt.close() + + +def test(times, value): + ret = [] + for x, y in [ + ('index_app_names', f"['{value}']"), + ('index_categories', f"['{value}']"), + ('bundle_combine', f"['{value}']"), + ('index_rank', f"['{value}']"), + ('index_domains', f"['{value}']"), + ('html_bundle', f"['{value}']"), + ('html_categories', ''), + ('html_index_apps', ''), + ('html_ranking', ''), + ('html_group_compare', ''), + ('html_index_domains', ''), + ('html_root', '1, 1, inclStatic=True') + ]: + sys.stdout = open(os.devnull, 'w') + t = timeit.timeit(f'process({y})', + setup=f'from {x} import process', + number=times) / times + sys.stdout = sys.__stdout__ + print(f"('{x}', {t}),") + ret.append((x, t)) + return ret + + +pre_calc = [ # 1.7468616582500003 + ('index_app_names', 0.05087930704999999), + ('index_categories', 0.03988175075), + ('bundle_combine', 0.89672237075), + ('index_rank', 0.09671105084999994), + ('index_domains', 0.08596107025000013), + ('html_bundle', 0.23503021030000007), + ('html_categories', 0.10772542440000006), + ('html_index_apps', 0.014855155450000091), + ('html_ranking', 0.04087204415000016), + ('html_group_compare', 0.004021174899999735), + ('html_index_domains', 0.04882671115000008), + ('html_root', 0.12537538825), +] +post_calc = [ # 0.5836890604499999 + ('index_app_names', 0.0006852585000000022), + ('index_categories', 0.0008334453500000005), + ('bundle_combine', 0.0136475935), + ('index_rank', 0.0012115025499999988), + ('index_domains', 0.0800649297), + ('html_bundle', 0.002384871350000006), + ('html_categories', 0.15204053159999997), + ('html_index_apps', 0.020598785899999993), + ('html_ranking', 0.059948232549999994), + ('html_group_compare', 0.004277908699999999), + ('html_index_domains', 0.06897567679999997), + ('html_root', 0.17902032395000003), +] +# gen_graph(pre_calc, 'times.svg') +# result = pre_calc +result = test(20, '*') +# result = test(20, 'com.amazon.AmazonDE') +print('pre_calc', sum([x for _, x in pre_calc])) +print('measure ', sum([x for _, x in result])) +gen_graph(result, 'times.svg') +# result1 = test(10, '*') +# result2 = test(10, 'com.amazon.AmazonDE') +# a = sum([x for _, x in result1]) +# b = sum([x for _, x in result2]) +# result2.append((' ', a - b)) +# gen_graph(result1, 'times1.svg') +# gen_graph(result2, 'times2.svg')