1 package org
.eclipse
.linuxtools
.lttng
.core
.tests
.headless
;
2 /*******************************************************************************
3 * Copyright (c) 2009 Ericsson
5 * All rights reserved. This program and the accompanying materials are
6 * made available under the terms of the Eclipse Public License v1.0 which
7 * accompanies this distribution, and is available at
8 * http://www.eclipse.org/legal/epl-v10.html
11 * William Bourque (wbourque@gmail.com) - Initial API and implementation
12 *******************************************************************************/
14 import org
.eclipse
.linuxtools
.lttng
.core
.event
.LttngEvent
;
15 import org
.eclipse
.linuxtools
.lttng
.core
.event
.LttngLocation
;
16 import org
.eclipse
.linuxtools
.lttng
.core
.event
.LttngTimestamp
;
17 import org
.eclipse
.linuxtools
.lttng
.core
.trace
.LTTngTextTrace
;
18 import org
.eclipse
.linuxtools
.lttng
.core
.trace
.LTTngTrace
;
19 import org
.eclipse
.linuxtools
.tmf
.core
.trace
.TmfContext
;
20 import org
.eclipse
.linuxtools
.tmf
.core
.trace
.TmfTrace
;
23 @SuppressWarnings("nls")
24 public class LttngTraceTest
{
29 public static void main(String
[] args
) {
32 final String TRACE_PATH
= "/home/francois/Desktop/Workspaces/LTTngTraces/trace_2GB";
34 // *** Change to true to use the "fake" LttngTextTrace instead of LTTngTrace
35 // To use this, you need a ".txt" trace.
36 // You can get it using LTTv with the command "lttv -m textDump -t /tmp/sometrace > mytrace.txt"
37 final boolean USE_TEXT_TRACE
= false;
39 // *** Change this to run several time over the same trace
40 final int NB_OF_PASS
= 1;
42 // *** Change this to true to parse all the events in the trace
43 // Otherwise, events are just read
44 final boolean PARSE_EVENTS
= true;
48 TmfTrace
<LttngEvent
> tmptrace
= null;
49 LttngEvent tmpevent
= null;
50 TmfContext tmpContext
= null;
54 // ** Use TextTrace (slow!) if it was asked
55 if ( USE_TEXT_TRACE
) {
56 tmptrace
= new LTTngTextTrace(TRACE_PATH
, true);
58 tmptrace
= new LTTngTrace(TRACE_PATH
, null, true, true);
61 LttngTimestamp tmpTime
= new LttngTimestamp(0L);
62 tmpContext
= new TmfContext(new LttngLocation(0L), 0);
65 long startTime
= System
.nanoTime();
66 System
.out
.println("Start: " + startTime
);
67 for ( int nb
=0; nb
<NB_OF_PASS
; nb
++) {
69 // Seek to the beginning of the trace
70 tmpContext
= tmptrace
.seekEvent( tmpTime
);
71 tmpevent
= (LttngEvent
)tmptrace
.getNextEvent(tmpContext
);
73 while ( tmpevent
!= null ) {
74 tmpevent
= (LttngEvent
)tmptrace
.getNextEvent(tmpContext
);
76 // Parse the events if it was asked
77 if ( (tmpevent
!= null) && (PARSE_EVENTS
) ) {
78 tmpevent
.getContent().getFields();
80 // *** Uncomment the following to print the parsed content
81 // Warning : this is VERY intensive
83 // System.out.println(tmpevent.toString());
84 //System.out.println(testEvent.getContent().toString());
91 System
.out
.println("NB events : " + nbEvent
);
93 long endTime
= System
.nanoTime();
94 long elapsed
= endTime
- startTime
;
95 System
.out
.println("End: " + endTime
);
96 System
.out
.println("Elapsed: " + elapsed
+ ", Average: " + (elapsed
/nbEvent
) + "ns/evt");
This page took 0.034169 seconds and 5 git commands to generate.