518 continue |
518 continue |
519 #sys.stderr.write( line ) |
519 #sys.stderr.write( line ) |
520 try: |
520 try: |
521 rql, time = line.split('--') |
521 rql, time = line.split('--') |
522 rql = re.sub("(\'\w+': \d*)", '', rql) |
522 rql = re.sub("(\'\w+': \d*)", '', rql) |
|
523 if '{' in rql: |
|
524 rql = rql[:rql.index('{')] |
523 req = requests.setdefault(rql, []) |
525 req = requests.setdefault(rql, []) |
524 time.strip() |
526 time.strip() |
525 chunks = time.split() |
527 chunks = time.split() |
526 cputime = float(chunks[-3]) |
528 cputime = float(chunks[-3]) |
527 req.append( cputime ) |
529 req.append( cputime ) |
528 except Exception, exc: |
530 except Exception, exc: |
529 sys.stderr.write('Line %s: %s\n' % (lineno, exc)) |
531 sys.stderr.write('Line %s: %s (%s)\n' % (lineno, exc, line)) |
530 |
532 |
531 stat = [] |
533 stat = [] |
532 for rql, times in requests.items(): |
534 for rql, times in requests.items(): |
533 stat.append( (sum(times), len(times), rql) ) |
535 stat.append( (sum(times), len(times), rql) ) |
534 |
536 |
535 stat.sort() |
537 stat.sort() |
536 stat.reverse() |
538 stat.reverse() |
537 print 'Time ; Occurences ; Query' |
539 |
|
540 total_time = sum(time for time, occ, rql in stat)*0.01 |
|
541 print 'Percentage;Cumulative Time;Occurences;Query' |
538 for time, occ, rql in stat: |
542 for time, occ, rql in stat: |
539 print time, ';', occ, ';', rql |
543 print '%.2f;%.2f;%s;%s' % (time/total_time, time, occ, rql) |
540 |
544 |
541 register_commands((UpdateCubicWebCatalogCommand, |
545 register_commands((UpdateCubicWebCatalogCommand, |
542 UpdateTemplateCatalogCommand, |
546 UpdateTemplateCatalogCommand, |
543 LiveServerCommand, |
547 LiveServerCommand, |
544 NewCubeCommand, |
548 NewCubeCommand, |