devtools/devctl.py
branchstable
changeset 2092 f5102472243d
parent 1977 606923dff11b
child 2395 e3093fc12a00
child 2446 440cb4ea7e5c
equal deleted inserted replaced
2091:a7ea618e5478 2092:f5102472243d
   570                 if '{' in rql:
   570                 if '{' in rql:
   571                     rql = rql[:rql.index('{')]
   571                     rql = rql[:rql.index('{')]
   572                 req = requests.setdefault(rql, [])
   572                 req = requests.setdefault(rql, [])
   573                 time.strip()
   573                 time.strip()
   574                 chunks = time.split()
   574                 chunks = time.split()
       
   575                 clocktime = float(chunks[0][1:])
   575                 cputime = float(chunks[-3])
   576                 cputime = float(chunks[-3])
   576                 req.append( cputime )
   577                 req.append( (clocktime, cputime) )
   577             except Exception, exc:
   578             except Exception, exc:
   578                 sys.stderr.write('Line %s: %s (%s)\n' % (lineno, exc, line))
   579                 sys.stderr.write('Line %s: %s (%s)\n' % (lineno, exc, line))
   579 
   580 
   580         stat = []
   581         stat = []
   581         for rql, times in requests.items():
   582         for rql, times in requests.items():
   582             stat.append( (sum(times), len(times), rql) )
   583             stat.append( (sum(time[0] for time in times),
       
   584                           sum(time[1] for time in times),
       
   585                           len(times), rql) )
   583 
   586 
   584         stat.sort()
   587         stat.sort()
   585         stat.reverse()
   588         stat.reverse()
   586 
   589 
   587         total_time = sum(time for time, occ, rql in stat)*0.01
   590         total_time = sum(clocktime for clocktime, cputime, occ, rql in stat)*0.01
   588         print 'Percentage;Cumulative Time;Occurences;Query'
   591         print 'Percentage;Cumulative Time (clock);Cumulative Time (CPU);Occurences;Query'
   589         for time, occ, rql in stat:
   592         for clocktime, cputime, occ, rql in stat:
   590             print '%.2f;%.2f;%s;%s' % (time/total_time, time, occ, rql)
   593             print '%.2f;%.2f;%.2f;%s;%s' % (clocktime/total_time, clocktime, cputime, occ, rql)
   591 
   594 
   592 register_commands((UpdateCubicWebCatalogCommand,
   595 register_commands((UpdateCubicWebCatalogCommand,
   593                    UpdateTemplateCatalogCommand,
   596                    UpdateTemplateCatalogCommand,
   594                    LiveServerCommand,
   597                    LiveServerCommand,
   595                    NewCubeCommand,
   598                    NewCubeCommand,