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 * Matthew Khouzam - Update to CtfTmf trace and events
12 *******************************************************************************/
14 package org
.eclipse
.linuxtools
.tmf
.core
.tests
.ctfadaptor
.headless
;
16 import java
.util
.Vector
;
18 import org
.eclipse
.linuxtools
.tmf
.core
.ctfadaptor
.CtfTmfEvent
;
19 import org
.eclipse
.linuxtools
.tmf
.core
.ctfadaptor
.CtfTmfTrace
;
20 import org
.eclipse
.linuxtools
.tmf
.core
.event
.ITmfEvent
;
21 import org
.eclipse
.linuxtools
.tmf
.core
.event
.TmfTimeRange
;
22 import org
.eclipse
.linuxtools
.tmf
.core
.request
.TmfEventRequest
;
23 import org
.eclipse
.linuxtools
.tmf
.core
.trace
.ITmfTrace
;
24 import org
.eclipse
.linuxtools
.tmf
.core
.trace
.TmfExperiment
;
27 * Benchmark the event request subsystem of TMF.
29 public class RequestBenchmark
extends TmfEventRequest
<CtfTmfEvent
> {
31 @SuppressWarnings("unchecked")
32 private RequestBenchmark(final Class
<?
extends ITmfEvent
> dataType
,
33 final TmfTimeRange range
, final int nbRequested
) {
34 super((Class
<CtfTmfEvent
>) dataType
, range
, nbRequested
, 1);
38 private static final String TRACE_PATH
= "../org.eclipse.linuxtools.ctf.core.tests/traces/kernel"; //$NON-NLS-1$
40 // Change this to run several time over the same trace
41 private static final int NB_OF_PASS
= 100;
44 private static int nbEvent
= 0;
45 private static TmfExperiment
<CtfTmfEvent
> fExperiment
= null;
46 private static Vector
<Double
> benchs
= new Vector
<Double
>();
52 * The command-line arguments
54 public static void main(final String
[] args
) {
57 /* Our experiment will contains ONE trace */
58 @SuppressWarnings("unchecked")
59 final ITmfTrace
<CtfTmfEvent
>[] traces
= new ITmfTrace
[1];
60 traces
[0] = new CtfTmfTrace();
61 traces
[0].initTrace(null, TRACE_PATH
, CtfTmfEvent
.class);
62 /* Create our new experiment */
63 fExperiment
= new TmfExperiment
<CtfTmfEvent
>(CtfTmfEvent
.class, "Headless", traces
); //$NON-NLS-1$
66 * We will issue a request for each "pass". TMF will then process
69 RequestBenchmark request
= null;
70 for (int x
= 0; x
< NB_OF_PASS
; x
++) {
71 request
= new RequestBenchmark(CtfTmfEvent
.class,
72 TmfTimeRange
.ETERNITY
, Integer
.MAX_VALUE
);
73 fExperiment
.sendRequest(request
);
75 prev
= System
.nanoTime();
76 } catch (final NullPointerException e
) {
78 * Silently dismiss Null pointer exception The only way to "finish"
79 * the threads in TMF is by crashing them with null.
81 } catch (final Exception e
) {
88 public void handleData(final CtfTmfEvent event
) {
89 super.handleData(event
);
97 public void handleCompleted() {
98 final long next
= System
.nanoTime();
99 double val
= next
- prev
;
100 final int nbEvent2
= nbEvent
;
106 if (benchs
.size() == NB_OF_PASS
) {
108 System
.out
.println("Nb events : " + nbEvent2
); //$NON-NLS-1$
110 for (final double value
: benchs
) {
111 System
.out
.print(value
+ ", "); //$NON-NLS-1$
113 fExperiment
.sendRequest(null);
115 } catch (final Exception e
) {
121 public void handleSuccess() {
125 public void handleFailure() {
129 public void handleCancel() {
This page took 0.035053 seconds and 5 git commands to generate.