1 /*******************************************************************************
2 * Copyright (c) 2012 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 * Alexandre Montplaisir - Initial API and implementation
11 ******************************************************************************/
13 package org
.eclipse
.linuxtools
.tmf
.core
.statistics
;
15 import org
.eclipse
.linuxtools
.tmf
.core
.event
.ITmfEvent
;
16 import org
.eclipse
.linuxtools
.tmf
.core
.exceptions
.AttributeNotFoundException
;
17 import org
.eclipse
.linuxtools
.tmf
.core
.exceptions
.StateValueTypeException
;
18 import org
.eclipse
.linuxtools
.tmf
.core
.exceptions
.TimeRangeException
;
19 import org
.eclipse
.linuxtools
.tmf
.core
.statesystem
.AbstractStateChangeInput
;
20 import org
.eclipse
.linuxtools
.tmf
.core
.statesystem
.ITmfStateSystemBuilder
;
21 import org
.eclipse
.linuxtools
.tmf
.core
.statistics
.TmfStatistics
.Attributes
;
22 import org
.eclipse
.linuxtools
.tmf
.core
.trace
.ITmfTrace
;
25 * The state provider for traces statistics. It should work with any type of
26 * trace TMF can handle.
28 * The resulting attribute tree will look like this:
37 * And each <event name>'s value will be an integer, representing how many times
38 * this particular event type has been seen in the trace so far.
40 * @author Alexandre Montplaisir
43 class StatsStateProvider
extends AbstractStateChangeInput
{
45 /* Commonly-used attributes */
46 private int typeAttribute
= -1;
52 * The trace for which we build this state system
54 public StatsStateProvider(ITmfTrace trace
) {
55 super(trace
, ITmfEvent
.class ,"TMF Statistics"); //$NON-NLS-1$
59 public void assignTargetStateSystem(ITmfStateSystemBuilder ssb
) {
60 super.assignTargetStateSystem(ssb
);
62 /* Setup common locations */
63 typeAttribute
= ss
.getQuarkAbsoluteAndAdd(Attributes
.EVENT_TYPES
);
67 protected void eventHandle(ITmfEvent event
) {
70 final long ts
= event
.getTimestamp().getValue();
71 final String eventName
= event
.getType().getName();
75 /* Number of events of each type, globally */
76 quark
= ss
.getQuarkRelativeAndAdd(typeAttribute
, eventName
);
77 ss
.incrementAttribute(ts
, quark
);
79 // /* Number of events per CPU */
80 // quark = ss.getQuarkRelativeAndAdd(currentCPUNode, Attributes.STATISTICS, Attributes.EVENT_TYPES, eventName);
81 // ss.incrementAttribute(ts, quark);
83 // /* Number of events per process */
84 // quark = ss.getQuarkRelativeAndAdd(currentThreadNode, Attributes.STATISTICS, Attributes.EVENT_TYPES, eventName);
85 // ss.incrementAttribute(ts, quark);
87 } catch (StateValueTypeException e
) {
89 } catch (TimeRangeException e
) {
91 } catch (AttributeNotFoundException e
) {