diff mbox

[1/6] trace: [tracetool] Do not rebuild event list in backend code

Message ID 20120111180504.25198.76946.stgit@ginnungagap.bsc.es
State New
Headers show

Commit Message

Lluís Vilanova Jan. 11, 2012, 6:05 p.m. UTC
Signed-off-by: Lluís Vilanova <vilanova@ac.upc.edu>
---
 scripts/tracetool.py |   14 +++++++-------
 1 files changed, 7 insertions(+), 7 deletions(-)

Comments

Harsh Prateek Bora Jan. 18, 2012, 9:22 a.m. UTC | #1
On 01/11/2012 11:35 PM, Lluís Vilanova wrote:
> Signed-off-by: Lluís Vilanova<vilanova@ac.upc.edu>
> ---
>   scripts/tracetool.py |   14 +++++++-------
>   1 files changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/scripts/tracetool.py b/scripts/tracetool.py
> index 6874f66..80e5684 100755
> --- a/scripts/tracetool.py
> +++ b/scripts/tracetool.py

[.. snip ..]

> @@ -510,14 +508,16 @@ class Event(object):
>
>   # Generator that yields Event objects given a trace-events file object
>   def read_events(fobj):
> +    res = []
>       event_num = 0
>       for line in fobj:
>           if not line.strip():
>               continue
>           if line.lstrip().startswith('#'):
>   	    continue
> -	yield Event(event_num, line)
> +	res.append(Event(event_num, line))
>   	event_num += 1
> +    return res
>

Hi Lluis,
This looks really nice. I can include your fixes while addressing other 
review comments. Shall I fold your patches with mine or do you want to 
keep them separate?

regards,
Harsh



>   backend = ""
>   output = ""
>
>
Lluís Vilanova Jan. 18, 2012, 11:45 a.m. UTC | #2
Harsh Bora writes:

> On 01/11/2012 11:35 PM, Lluís Vilanova wrote:
>> Signed-off-by: Lluís Vilanova<vilanova@ac.upc.edu>
>> ---
>> scripts/tracetool.py |   14 +++++++-------
>> 1 files changed, 7 insertions(+), 7 deletions(-)
>> 
>> diff --git a/scripts/tracetool.py b/scripts/tracetool.py
>> index 6874f66..80e5684 100755
>> --- a/scripts/tracetool.py
>> +++ b/scripts/tracetool.py

> [.. snip ..]

>> @@ -510,14 +508,16 @@ class Event(object):
>> 
>> # Generator that yields Event objects given a trace-events file object
>> def read_events(fobj):
>> +    res = []
>> event_num = 0
>> for line in fobj:
>> if not line.strip():
>> continue
>> if line.lstrip().startswith('#'):
>> continue
>> -	yield Event(event_num, line)
>> +	res.append(Event(event_num, line))
>> event_num += 1
>> +    return res
>> 

> Hi Lluis,
> This looks really nice. I can include your fixes while addressing other review
> comments. Shall I fold your patches with mine or do you want to keep them
> separate?

Whatever works best for you.


Lluis
Lluís Vilanova Jan. 18, 2012, noon UTC | #3
Lluís Vilanova writes:

> Harsh Bora writes:

>> Hi Lluis,
>> This looks really nice. I can include your fixes while addressing other review
>> comments. Shall I fold your patches with mine or do you want to keep them
>> separate?

> Whatever works best for you.

BTW, I did some more changes, but didn't care to separate them into more
patches, so maybe I'll send you a few more on the next version.


Lluis
diff mbox

Patch

diff --git a/scripts/tracetool.py b/scripts/tracetool.py
index 6874f66..80e5684 100755
--- a/scripts/tracetool.py
+++ b/scripts/tracetool.py
@@ -171,15 +171,14 @@  def simple_c(events):
     print
     print 'TraceEvent trace_list[] = {'
     print
-    eventlist = list(events)
-    for event in eventlist:
+    for event in events:
         print '{.tp_name = "%(name)s", .state=0},' % {
     'name': event.name
 }
         print
     print '};'
     print
-    for event in eventlist:
+    for event in events:
         argc = event.argc
         print '''void trace_%(name)s(%(args)s)
 {
@@ -311,8 +310,7 @@  def ust_c(events):
 #undef inline
 #undef wmb
 #include "trace.h"'''
-    eventlist = list(events)
-    for event in eventlist:
+    for event in events:
         argnames = event.argnames
         if event.argc > 0:
             argnames = ', ' + event.argnames
@@ -344,7 +342,7 @@  static void ust_%(name)s_probe(%(args)s)
     print '''
 static void __attribute__((constructor)) trace_init(void)
 {'''
-    for event in eventlist:
+    for event in events:
         print '    register_trace_ust_%(name)s(ust_%(name)s_probe);' % {
     'name': event.name
 }
@@ -510,14 +508,16 @@  class Event(object):
 
 # Generator that yields Event objects given a trace-events file object
 def read_events(fobj):
+    res = []
     event_num = 0
     for line in fobj:
         if not line.strip():
             continue
         if line.lstrip().startswith('#'):
 	    continue
-	yield Event(event_num, line)
+	res.append(Event(event_num, line))
 	event_num += 1
+    return res
 
 backend = ""
 output = ""