tmf: Use tabs in statistics view for each traces
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng.core.tests / src / org / eclipse / linuxtools / lttng / core / tests / headless / LttngTraceTest.java
CommitLineData
6c13869b 1package org.eclipse.linuxtools.lttng.core.tests.headless;
9cb4892d
WB
2/*******************************************************************************
3 * Copyright (c) 2009 Ericsson
0c32e4c5 4 *
9cb4892d
WB
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
0c32e4c5 9 *
9cb4892d
WB
10 * Contributors:
11 * William Bourque (wbourque@gmail.com) - Initial API and implementation
12 *******************************************************************************/
13
5945cec9
FC
14import org.eclipse.linuxtools.internal.lttng.core.event.LttngEvent;
15import org.eclipse.linuxtools.internal.lttng.core.event.LttngLocation;
16import org.eclipse.linuxtools.internal.lttng.core.event.LttngTimestamp;
17import org.eclipse.linuxtools.internal.lttng.core.trace.LTTngTextTrace;
18import org.eclipse.linuxtools.internal.lttng.core.trace.LTTngTrace;
3791b5df 19import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
6c13869b
FC
20import org.eclipse.linuxtools.tmf.core.trace.TmfContext;
21import org.eclipse.linuxtools.tmf.core.trace.TmfTrace;
9cb4892d
WB
22
23
3b38ea61 24@SuppressWarnings("nls")
9cb4892d
WB
25public class LttngTraceTest {
26
25e48683
FC
27 /**
28 * @param args
29 */
30 public static void main(final String[] args) {
31
32 // Path of the trace
cb866e08 33 final String TRACE_PATH = "/home/francois/Desktop/Workspaces/LTTngTraces/trace_2GB";
9cb4892d 34 // *** Change to true to use the "fake" LttngTextTrace instead of LTTngTrace
25e48683
FC
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"
9cb4892d 37 final boolean USE_TEXT_TRACE = false;
25e48683 38
9cb4892d
WB
39 // *** Change this to run several time over the same trace
40 final int NB_OF_PASS = 1;
25e48683 41
9cb4892d
WB
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;
25e48683
FC
45
46
9cb4892d 47 // Work variables
0c32e4c5 48 TmfTrace tmptrace = null;
9cb4892d 49 LttngEvent tmpevent = null;
3791b5df 50 ITmfContext tmpContext = null;
9cb4892d 51 Long nbEvent = 0L;
25e48683
FC
52
53 try {
54 // ** Use TextTrace (slow!) if it was asked
0c32e4c5 55 if ( USE_TEXT_TRACE ) {
25e48683 56 tmptrace = new LTTngTextTrace(null, TRACE_PATH, true);
0c32e4c5 57 } else {
25e48683 58 tmptrace = new LTTngTrace(null, TRACE_PATH, null, true, true);
0c32e4c5 59 }
25e48683
FC
60
61 final LttngTimestamp tmpTime = new LttngTimestamp(0L);
9cb4892d 62 tmpContext = new TmfContext(new LttngLocation(0L), 0);
cb866e08 63
25e48683
FC
64
65 final long startTime = System.nanoTime();
cb866e08
FC
66 System.out.println("Start: " + startTime);
67 for ( int nb=0; nb<NB_OF_PASS; nb++) {
25e48683
FC
68
69 // Seek to the beginning of the trace
70 tmpContext = tmptrace.seekEvent( tmpTime );
c32744d6 71 tmpevent = (LttngEvent)tmptrace.getNext(tmpContext);
25e48683
FC
72
73 while ( tmpevent != null ) {
c32744d6 74 tmpevent = (LttngEvent)tmptrace.getNext(tmpContext);
25e48683
FC
75
76 // Parse the events if it was asked
0c32e4c5 77 if ( (tmpevent != null) && (PARSE_EVENTS) ) {
25e48683 78 tmpevent.getContent().getFields();
0c32e4c5 79 }
25e48683
FC
80
81 nbEvent++;
82 }
83 }
84
85 System.out.println("NB events : " + nbEvent);
86
87 final long endTime = System.nanoTime();
88 final long elapsed = endTime - startTime;
89 System.out.println("End: " + endTime);
90 System.out.println("Elapsed: " + elapsed + ", Average: " + (elapsed/nbEvent) + "ns/evt");
91
92 }
93 catch (final Exception e) {
94 e.printStackTrace();
95 }
96
97 }
9cb4892d
WB
98
99}
This page took 0.036825 seconds and 5 git commands to generate.