/*
* Debellor
*
* Copyright (C) 2008-2009 by Marcin Wojnarski
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see http://www.gnu.org/licenses/.
*/
package org.debellor.core.util;
import org.debellor.core.Cell;
public class CellStats {
private static final double NANO = 1.0 / 1000000000;
//public final Map<String,Object> map = new HashMap<String,Object>();
private long startNext;
private long timeNext;
private long startWait;
private long timeWait;
private long timeNextTotal;
private long timeWaitTotal;
void preNext() { startNext = System.nanoTime(); }
void postNext() { timeNext = System.nanoTime() - startNext;
timeNextTotal += timeNext;
}
void preWait() { startWait = System.nanoTime(); }
void postWait() { timeWait = System.nanoTime() - startWait;
timeWaitTotal += timeWait;
}
/** Total execution time of all calls to {@link Cell#onNext()}, in seconds. */
public double timeOfAllNext() { return timeNextTotal * NANO; }
/** In multithreaded execution of {@link Cell#onNext()}, total time of retrieving
* of next samples from the working thread, in seconds. */
public double timeOfAllWait() { return timeWaitTotal * NANO; }
}