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(final String[] args) {
33
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
ITmfContext tmpContext = null;
54
// ** Use TextTrace (slow!) if it was asked
56
tmptrace = new LTTngTextTrace(null, TRACE_PATH, true);
58
tmptrace = new LTTngTrace(null, TRACE_PATH, null, true, true);
60
final LttngTimestamp tmpTime = new LttngTimestamp(0L);
61
tmpContext = new TmfContext(new LttngLocation(0L), 0);
64
final long startTime = System.nanoTime();
65
System.out.println("Start: " + startTime);
66
for ( int nb=0; nb<NB_OF_PASS; nb++) {
68
// Seek to the beginning of the trace
69
tmpContext = tmptrace.seekEvent( tmpTime );
70
tmpevent = (LttngEvent)tmptrace.getNext(tmpContext);
72
while ( tmpevent != null ) {
73
tmpevent = (LttngEvent)tmptrace.getNext(tmpContext);
75
// Parse the events if it was asked
76
if ( (tmpevent != null) && (PARSE_EVENTS) )
77
tmpevent.getContent().getFields();
83
System.out.println("NB events : " + nbEvent);
85
final long endTime = System.nanoTime();
86
final long elapsed = endTime - startTime;
87
System.out.println("End: " + endTime);
88
System.out.println("Elapsed: " + elapsed + ", Average: " + (elapsed/nbEvent) + "ns/evt");
91
catch (final Exception e) {