cleanups, vipsprofile.py now works
This commit is contained in:
parent
5810ac761e
commit
d366320cb1
@ -37,36 +37,6 @@ extern "C" {
|
|||||||
|
|
||||||
#include <vips/vips.h>
|
#include <vips/vips.h>
|
||||||
|
|
||||||
#define VIPS_GATE_SIZE (10000)
|
|
||||||
|
|
||||||
/* A set of timing records. i is the index of the next slot we fill.
|
|
||||||
*/
|
|
||||||
typedef struct _VipsThreadGateBlock {
|
|
||||||
struct _VipsThreadGateBlock *prev;
|
|
||||||
|
|
||||||
gint64 time[VIPS_GATE_SIZE];
|
|
||||||
int i;
|
|
||||||
} VipsThreadGateBlock;
|
|
||||||
|
|
||||||
/* What we track for each gate-name.
|
|
||||||
*/
|
|
||||||
typedef struct _VipsThreadGate {
|
|
||||||
const char *name;
|
|
||||||
VipsThreadGateBlock *start;
|
|
||||||
VipsThreadGateBlock *stop;
|
|
||||||
} VipsThreadGate;
|
|
||||||
|
|
||||||
/* One of these in per-thread private storage.
|
|
||||||
*/
|
|
||||||
|
|
||||||
typedef struct _VipsThreadProfile {
|
|
||||||
/*< private >*/
|
|
||||||
|
|
||||||
const char *name;
|
|
||||||
GThread *thread;
|
|
||||||
GHashTable *gates;
|
|
||||||
} VipsThreadProfile;
|
|
||||||
|
|
||||||
#define VIPS_GATE_START( NAME ) \
|
#define VIPS_GATE_START( NAME ) \
|
||||||
G_STMT_START { \
|
G_STMT_START { \
|
||||||
if( vips__thread_profile ) \
|
if( vips__thread_profile ) \
|
||||||
|
@ -42,6 +42,36 @@
|
|||||||
#include <vips/vips.h>
|
#include <vips/vips.h>
|
||||||
#include <vips/internal.h>
|
#include <vips/internal.h>
|
||||||
|
|
||||||
|
#define VIPS_GATE_SIZE (1000)
|
||||||
|
|
||||||
|
/* A set of timing records. i is the index of the next slot we fill.
|
||||||
|
*/
|
||||||
|
typedef struct _VipsThreadGateBlock {
|
||||||
|
struct _VipsThreadGateBlock *prev;
|
||||||
|
|
||||||
|
gint64 time[VIPS_GATE_SIZE];
|
||||||
|
int i;
|
||||||
|
} VipsThreadGateBlock;
|
||||||
|
|
||||||
|
/* What we track for each gate-name.
|
||||||
|
*/
|
||||||
|
typedef struct _VipsThreadGate {
|
||||||
|
const char *name;
|
||||||
|
VipsThreadGateBlock *start;
|
||||||
|
VipsThreadGateBlock *stop;
|
||||||
|
} VipsThreadGate;
|
||||||
|
|
||||||
|
/* One of these in per-thread private storage.
|
||||||
|
*/
|
||||||
|
|
||||||
|
typedef struct _VipsThreadProfile {
|
||||||
|
/*< private >*/
|
||||||
|
|
||||||
|
const char *name;
|
||||||
|
GThread *thread;
|
||||||
|
GHashTable *gates;
|
||||||
|
} VipsThreadProfile;
|
||||||
|
|
||||||
gboolean vips__thread_profile = FALSE;
|
gboolean vips__thread_profile = FALSE;
|
||||||
|
|
||||||
static GPrivate *vips_thread_profile_key = NULL;
|
static GPrivate *vips_thread_profile_key = NULL;
|
||||||
|
@ -31,24 +31,25 @@ def read_times(rf):
|
|||||||
match = re.match('[0-9]+ ', rf.line)
|
match = re.match('[0-9]+ ', rf.line)
|
||||||
if not match:
|
if not match:
|
||||||
break
|
break
|
||||||
times.append([int(x) for x in re.split(' ', rf.line.rstrip())])
|
times += [int(x) for x in re.split(' ', rf.line.rstrip())]
|
||||||
rf.getnext()
|
rf.getnext()
|
||||||
|
|
||||||
return times[::-1]
|
return times[::-1]
|
||||||
|
|
||||||
class Event:
|
class Event:
|
||||||
def __init__(self, thread_name, thread_addr, gate_name, start, end):
|
def __init__(self, thread_name, thread_addr, gate_name, start, stop):
|
||||||
self.thread_name = thread_name
|
self.thread_name = thread_name
|
||||||
self.thread_addr = thread_addr
|
self.thread_addr = thread_addr
|
||||||
self.gate_name = gate_name
|
self.gate_name = gate_name
|
||||||
self.start = start
|
self.start = start
|
||||||
self.end = end
|
self.stop = stop
|
||||||
|
|
||||||
if re.match(': work', gate_name):
|
if re.match(': work', gate_name):
|
||||||
self.work = True
|
self.work = True
|
||||||
if re.match(': wait', gate_name):
|
if re.match(': wait', gate_name):
|
||||||
self.wait = True
|
self.wait = True
|
||||||
|
|
||||||
|
events = []
|
||||||
with ReadFile('vips-profile.txt') as rf:
|
with ReadFile('vips-profile.txt') as rf:
|
||||||
while rf:
|
while rf:
|
||||||
match = re.match('thread: (.*) \(0x([0-9a-f]+)\)', rf.line)
|
match = re.match('thread: (.*) \(0x([0-9a-f]+)\)', rf.line)
|
||||||
@ -81,3 +82,11 @@ with ReadFile('vips-profile.txt') as rf:
|
|||||||
|
|
||||||
if len(start) != len(stop):
|
if len(start) != len(stop):
|
||||||
print 'start and stop length mismatch'
|
print 'start and stop length mismatch'
|
||||||
|
|
||||||
|
for a, b in zip(start, stop):
|
||||||
|
event = Event(thread_name, thread_addr, gate_name, a, b)
|
||||||
|
events.append(event)
|
||||||
|
|
||||||
|
events.sort(lambda x, y: cmp(x.start, y.start))
|
||||||
|
|
||||||
|
print 'loaded %d events' % len(events)
|
||||||
|
Loading…
Reference in New Issue
Block a user