@@ -0,0 +1,2178 @@
+package cz.cuni.mff.d3s.spl.agent;%0A%0Aimport cz.cuni.mff.d3s.spl.core.data.SampleStorage;%0Aimport cz.cuni.mff.d3s.spl.core.data.instrumentation.InstrumentingDataSource;%0Aimport ch.usi.dag.disl.annotation.After;%0Aimport ch.usi.dag.disl.annotation.Before;%0Aimport ch.usi.dag.disl.annotation.SyntheticLocal;%0Aimport ch.usi.dag.disl.annotation.SyntheticStaticField;%0Aimport ch.usi.dag.disl.annotation.SyntheticStaticField.Scope;%0Aimport ch.usi.dag.disl.marker.BodyMarker;%0Aimport ch.usi.dag.disl.staticcontext.MethodStaticContext;%0A%0Apublic class NoReloadSnippets %7B%0A%09@SyntheticLocal%0A%09private static final int SKIP_COUNT = 10;%0A%09%0A%09@SyntheticLocal%0A%09private static long startTime = 0;%0A%09%0A%09/** Whether to skip current measurement. */%0A%09@SyntheticLocal%0A%09private static boolean skip = false;%0A%09%0A%09@SyntheticStaticField(scope=Scope.PERCLASS)%0A%09public static boolean measureThisClass = false;%0A%09%0A%09@SyntheticStaticField(scope=Scope.PERMETHOD)%0A%09private static int methodSkipCounter = 0;%0A%0A%09@Before(marker = BodyMarker.class, guard = Access.class)%0A%09public static void startMeasuring() %7B%0A%09%09/*%0A%09%09 * If we are not supposed to measure this method, just bail%0A%09%09 * out immediately.%0A%09%09 * %0A%09%09 */%0A%09%09if (!measureThisClass) %7B%0A%09%09%09return;%0A%09%09%7D%0A%09%09%0A%09%09/*%0A%09%09 * See if this run shall be measured.%0A%09%09 */%0A%09%09// FIXME: randomize, this is way to predictable%0A%09%09methodSkipCounter++;%0A%09%09if (methodSkipCounter %3C SKIP_COUNT) %7B%0A%09%09%09skip = true;%0A%09%09%09return;%0A%09%09%7D%0A%09%09%0A%09%09/*%0A%09%09 * Start the measuring.%0A%09%09 * Also, we need to reset the counter.%0A%09%09 */%0A%09%09methodSkipCounter = 0;%0A%09%09startTime = System.nanoTime();%0A%09%7D%0A%0A%09@After(marker = BodyMarker.class, guard = Access.class)%0A%09public static void endMeasureAnnounceResults(MethodStaticContext sc) %7B%0A%09%09/*%0A%09%09 * If this run is not measure or we do not measure at all,%0A%09%09 * we return immediately.%0A%09%09 */%0A%09%09if (!measureThisClass) %7B%0A%09%09%09return;%0A%09%09%7D%0A%09%09if (skip) %7B%0A%09%09%09skip = false;%0A%09%09%09return;%0A%09%09%7D%0A%09%09%0A%09%09/*%0A%09%09 * Finish the measuring.%0A%09%09 */%0A%09%09long now = System.nanoTime();%0A%09%09%0A%09%09// TODO: cache the storage in method static local%0A%09%09String id = InstrumentingDataSource.createId(sc.thisClassName(), sc.thisMethodName());%0A%09%09SampleStorage storage = Access.getSampleStorage(id);%0A%09%09storage.addFromNanoTimeRange(startTime, now);%0A%09%7D%0A%7D%0A

Add less-overhead measuring snippets