Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 191246
b: refs/heads/master
c: 9df9bbb
h: refs/heads/master
v: v3
  • Loading branch information
Frederic Weisbecker committed Apr 24, 2010
1 parent d2604de commit 22d28e8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 108 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: e0a808c65c23f88e48a5fff48775b90e7919c64f
refs/heads/master: 9df9bbba9f7e2e4ffdc51bbbfa524b67691321d2
112 changes: 5 additions & 107 deletions trunk/tools/perf/builtin-timechart.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,6 @@ struct wake_event {
static struct power_event *power_events;
static struct wake_event *wake_events;

struct sample_wrapper *all_samples;


struct process_filter;
struct process_filter {
char *name;
Expand Down Expand Up @@ -566,88 +563,6 @@ static void end_sample_processing(void)
}
}

static u64 sample_time(event_t *event, const struct perf_session *session)
{
int cursor;

cursor = 0;
if (session->sample_type & PERF_SAMPLE_IP)
cursor++;
if (session->sample_type & PERF_SAMPLE_TID)
cursor++;
if (session->sample_type & PERF_SAMPLE_TIME)
return event->sample.array[cursor];
return 0;
}


/*
* We first queue all events, sorted backwards by insertion.
* The order will get flipped later.
*/
static int queue_sample_event(event_t *event, struct perf_session *session)
{
struct sample_wrapper *copy, *prev;
int size;

size = event->sample.header.size + sizeof(struct sample_wrapper) + 8;

copy = malloc(size);
if (!copy)
return 1;

memset(copy, 0, size);

copy->next = NULL;
copy->timestamp = sample_time(event, session);

memcpy(&copy->data, event, event->sample.header.size);

/* insert in the right place in the list */

if (!all_samples) {
/* first sample ever */
all_samples = copy;
return 0;
}

if (all_samples->timestamp < copy->timestamp) {
/* insert at the head of the list */
copy->next = all_samples;
all_samples = copy;
return 0;
}

prev = all_samples;
while (prev->next) {
if (prev->next->timestamp < copy->timestamp) {
copy->next = prev->next;
prev->next = copy;
return 0;
}
prev = prev->next;
}
/* insert at the end of the list */
prev->next = copy;

return 0;
}

static void sort_queued_samples(void)
{
struct sample_wrapper *cursor, *next;

cursor = all_samples;
all_samples = NULL;

while (cursor) {
next = cursor->next;
cursor->next = all_samples;
all_samples = cursor;
cursor = next;
}
}

/*
* Sort the pid datastructure
*/
Expand Down Expand Up @@ -1011,26 +926,12 @@ static void write_svg_file(const char *filename)
svg_close();
}

static void process_samples(struct perf_session *session)
{
struct sample_wrapper *cursor;
event_t *event;

sort_queued_samples();

cursor = all_samples;
while (cursor) {
event = (void *)&cursor->data;
cursor = cursor->next;
process_sample_event(event, session);
}
}

static struct perf_event_ops event_ops = {
.comm = process_comm_event,
.fork = process_fork_event,
.exit = process_exit_event,
.sample = queue_sample_event,
.comm = process_comm_event,
.fork = process_fork_event,
.exit = process_exit_event,
.sample = process_sample_event,
.ordered_samples = true,
};

static int __cmd_timechart(void)
Expand All @@ -1048,8 +949,6 @@ static int __cmd_timechart(void)
if (ret)
goto out_delete;

process_samples(session);

end_sample_processing();

sort_pids();
Expand All @@ -1072,7 +971,6 @@ static const char *record_args[] = {
"record",
"-a",
"-R",
"-M",
"-f",
"-c", "1",
"-e", "power:power_start",
Expand Down

0 comments on commit 22d28e8

Please sign in to comment.