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
.internal
.lttng
.core
.event
.LttngEvent
;
15 import org
.eclipse
.linuxtools
.internal
.lttng
.core
.event
.LttngLocation
;
16 import org
.eclipse
.linuxtools
.internal
.lttng
.core
.event
.LttngTimestamp
;
17 import org
.eclipse
.linuxtools
.internal
.lttng
.core
.trace
.LTTngTextTrace
;
18 import org
.eclipse
.linuxtools
.internal
.lttng
.core
.trace
.LTTngTrace
;
19 import org
.eclipse
.linuxtools
.tmf
.core
.trace
.ITmfContext
;
20 import org
.eclipse
.linuxtools
.tmf
.core
.trace
.TmfContext
;
21 import org
.eclipse
.linuxtools
.tmf
.core
.trace
.TmfTrace
;
24 @SuppressWarnings("nls")
25 public class LttngTraceTest
{
30 public static void main(String
[] args
) {
33 final String TRACE_PATH
= "/home/francois/Desktop/Workspaces/LTTngTraces/trace_2GB";
34 final String TRACE_NAME
= "trace_2GB";
36 // *** Change to true to use the "fake" LttngTextTrace instead of LTTngTrace
37 // To use this, you need a ".txt" trace.
38 // You can get it using LTTv with the command "lttv -m textDump -t /tmp/sometrace > mytrace.txt"
39 final boolean USE_TEXT_TRACE
= false;
41 // *** Change this to run several time over the same trace
42 final int NB_OF_PASS
= 1;
44 // *** Change this to true to parse all the events in the trace
45 // Otherwise, events are just read
46 final boolean PARSE_EVENTS
= true;
50 TmfTrace
<LttngEvent
> tmptrace
= null;
51 LttngEvent tmpevent
= null;
52 ITmfContext tmpContext
= null;
56 // ** Use TextTrace (slow!) if it was asked
57 if ( USE_TEXT_TRACE
) {
58 tmptrace
= new LTTngTextTrace(TRACE_NAME
, TRACE_PATH
, true);
60 tmptrace
= new LTTngTrace(TRACE_NAME
, TRACE_PATH
, null, true, true);
63 LttngTimestamp tmpTime
= new LttngTimestamp(0L);
64 tmpContext
= new TmfContext(new LttngLocation(0L), 0);
67 long startTime
= System
.nanoTime();
68 System
.out
.println("Start: " + startTime
);
69 for ( int nb
=0; nb
<NB_OF_PASS
; nb
++) {
71 // Seek to the beginning of the trace
72 tmpContext
= tmptrace
.seekEvent( tmpTime
);
73 tmpevent
= (LttngEvent
)tmptrace
.getNextEvent(tmpContext
);
75 while ( tmpevent
!= null ) {
76 tmpevent
= (LttngEvent
)tmptrace
.getNextEvent(tmpContext
);
78 // Parse the events if it was asked
79 if ( (tmpevent
!= null) && (PARSE_EVENTS
) ) {
80 tmpevent
.getContent().getFields();
82 // *** Uncomment the following to print the parsed content
83 // Warning : this is VERY intensive
85 // System.out.println(tmpevent.toString());
86 //System.out.println(testEvent.getContent().toString());
93 System
.out
.println("NB events : " + nbEvent
);
95 long endTime
= System
.nanoTime();
96 long elapsed
= endTime
- startTime
;
97 System
.out
.println("End: " + endTime
);
98 System
.out
.println("Elapsed: " + elapsed
+ ", Average: " + (elapsed
/nbEvent
) + "ns/evt");
101 catch (Exception e
) {
This page took 0.033641 seconds and 5 git commands to generate.