1 /*******************************************************************************
2 * Copyright (c) 2009 Ericsson
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * William Bourque (wbourque@gmail.com) - Initial API and implementation
11 *******************************************************************************/
13 import org
.eclipse
.linuxtools
.lttng
.event
.LttngEvent
;
14 import org
.eclipse
.linuxtools
.lttng
.event
.LttngLocation
;
15 import org
.eclipse
.linuxtools
.lttng
.event
.LttngTimestamp
;
16 import org
.eclipse
.linuxtools
.lttng
.trace
.LTTngTextTrace
;
17 import org
.eclipse
.linuxtools
.lttng
.trace
.LTTngTrace
;
18 import org
.eclipse
.linuxtools
.tmf
.trace
.TmfContext
;
19 import org
.eclipse
.linuxtools
.tmf
.trace
.TmfTrace
;
22 public class LttngTraceTest
{
27 public static void main(String
[] args
) {
30 final String TRACE_PATH
= "/home/francois/Desktop/Workspaces/LTTngTraces/trace_2GB";
32 // *** Change to true to use the "fake" LttngTextTrace instead of LTTngTrace
33 // To use this, you need a ".txt" trace.
34 // You can get it using LTTv with the command "lttv -m textDump -t /tmp/sometrace > mytrace.txt"
35 final boolean USE_TEXT_TRACE
= false;
37 // *** Change this to run several time over the same trace
38 final int NB_OF_PASS
= 1;
40 // *** Change this to true to parse all the events in the trace
41 // Otherwise, events are just read
42 final boolean PARSE_EVENTS
= true;
46 TmfTrace
<LttngEvent
> tmptrace
= null;
47 LttngEvent tmpevent
= null;
48 TmfContext tmpContext
= null;
52 // ** Use TextTrace (slow!) if it was asked
53 if ( USE_TEXT_TRACE
) {
54 tmptrace
= new LTTngTextTrace(TRACE_PATH
, true);
56 tmptrace
= new LTTngTrace(TRACE_PATH
, true, true);
59 LttngTimestamp tmpTime
= new LttngTimestamp(0L);
60 tmpContext
= new TmfContext(new LttngLocation(0L), 0);
63 long startTime
= System
.nanoTime();
64 System
.out
.println("Start: " + startTime
);
65 for ( int nb
=0; nb
<NB_OF_PASS
; nb
++) {
67 // Seek to the beginning of the trace
68 tmpContext
= tmptrace
.seekEvent( tmpTime
);
69 tmpevent
= (LttngEvent
)tmptrace
.getNextEvent(tmpContext
);
71 while ( tmpevent
!= null ) {
72 tmpevent
= (LttngEvent
)tmptrace
.getNextEvent(tmpContext
);
74 // Parse the events if it was asked
75 if ( (tmpevent
!= null) && (PARSE_EVENTS
) ) {
76 tmpevent
.getContent().getFields();
78 // *** Uncomment the following to print the parsed content
79 // Warning : this is VERY intensive
81 // System.out.println(tmpevent.toString());
82 //System.out.println(testEvent.getContent().toString());
89 System
.out
.println("NB events : " + nbEvent
);
91 long endTime
= System
.nanoTime();
92 long elapsed
= endTime
- startTime
;
93 System
.out
.println("End: " + endTime
);
94 System
.out
.println("Elapsed: " + elapsed
+ ", Average: " + (elapsed
/nbEvent
) + "ns/evt");
This page took 0.03603 seconds and 5 git commands to generate.