#!/usr/bin/python # Minas Gjoka import urllib,re, sys, time, random, datetime, time,csv, os import Gnuplot, Gnuplot.funcutils try: filename = sys.argv[1] except: print 'Usage:', sys.argv[0], 'filename' sys.exit(1) postfix = os.path.split(filename)[1] fin = open(filename,"r") v = {} counter = 0 for element in fin: v[ int(element) ] = v.get( int(element), 0 ) + 1 counter = counter + 1 if (counter % 10**6 ==0): print "%d users counted" % counter list = v.keys() list.sort() fout = open("simulation-apps-peruser_%s.dat" % (postfix),"w") fout.write("#Numofapps Instances\n") for i in list: fout.write("%d %d\n" % (i, v[i])) fout.close() g = Gnuplot.Gnuplot(debug=0) g('set grid') g('set xlabel "Number of applications installed') g('set ylabel "Number of users') g('set logscale x') g('set logscale y') #g('set style data histogram') #g('set style fill solid border -1') g('set terminal postscript color enhanced "Arial" 22') g('set output "simulation-apps-peruser_%s.eps"' % (postfix)) g('plot "simulation-apps-peruser_%s.dat" using 1:2 with linespoints title "Applications per user"' % (postfix)) ##############Combine different simulation results + real data results#################### g = Gnuplot.Gnuplot(debug=0) g('set grid') g('set xlabel "Number of applications installed') g('set ylabel "Number of users') g('set logscale x') g('set logscale y') g('set pointsize 1.5') #g('set style data histogram') #g('set style fill solid border -1') g('set terminal postscript monochrome enhanced "Arial" 20') g('set output "simulation-apps-peruser_allcombined.eps"') g('plot "all-profiles/apps-peruser.dat" using 1:2 with linespoints title "Crawled Data",\ "simulation-apps-peruser_uniform-at-random-numofapps-peruser-all-profiles-installs-foreachapp-withoutexcludedapps.dat" using 1:2 with linespoints pt 13 title "Uniform at Random",\ "simulation-apps-peruser_numofapps-peruser-all-profiles-installs-foreachapp-withoutexcludedapps.dat" using 1:2 with linespoints title "Preferential with {/Symbol r}=1.6" ') #"simulation-apps-peruser_full-run-numofapps-peruser-all-profiles-installs-foreachapp.dat" using 1:2 with linespoints title "Preferential with a=1",\