All Downloads are FREE. Search and download functionalities are using the official Maven repository.

Alachisoft.NCache.Common.Stats.NanoSecTimeStats Maven / Gradle / Ivy

There is a newer version: 5.3.3
Show newest version
package Alachisoft.NCache.Common.Stats;

public class NanoSecTimeStats //implements Serializable
{

    private long start;
    private long stop;
    private long frequency;
//	private java.math.BigDecimal multiplier = new java.math.BigDecimal(1.0e9);
//

    public NanoSecTimeStats() {
////C# TO JAVA CONVERTER TODO TASK: There is no preprocessor in Java:
////#if !MONO
//		tangible.RefObject tempRef_frequency = new tangible.RefObject(frequency);
//		boolean tempVar = Win32.QueryPerformanceFrequency(tempRef_frequency) == false;
//			frequency = tempRef_frequency.argvalue;
//		if (tempVar) {
//			// Frequency not supported
//			throw new RuntimeException("frequency not supported");
//		}
////#else
//		//@UH
////#endif
    }
//

    public final void Start() {
        start = System.nanoTime();
////C# TO JAVA CONVERTER TODO TASK: There is no preprocessor in Java:
////#if !MONO
//		tangible.RefObject tempRef_start = new tangible.RefObject(start);
//		Win32.QueryPerformanceCounter(tempRef_start);
//		start = tempRef_start.argvalue;
////#else
//		//@UH
////#endif
    }
//

    public final void Stop() {
        stop = System.nanoTime();
////C# TO JAVA CONVERTER TODO TASK: There is no preprocessor in Java:
////#if !MONO
//		tangible.RefObject tempRef_stop = new tangible.RefObject(stop);
//		Win32.QueryPerformanceCounter(tempRef_stop);
//		stop = tempRef_stop.argvalue;
////#else
//		//@UH
////#endif
    }

    /**
     * returns the nanoseconds per iteration.
     *
     * @param iterations total iterations.
     * @return Nanoseconds per Iteration.
     */
    public final double Duration(int iterations) {
        return (stop - start) / (double) iterations;
        //return ((((double) (stop - start) * (double) multiplier) / (double) frequency) / iterations);
    }
//
////C# TO JAVA CONVERTER TODO TASK: There is no preprocessor in Java:
//		///#region ICompactSerializable Members
//
//	//public void Deserialize(CompactReader reader)
//	//{
//	//    start = reader.ReadInt64();
//	//    stop = reader.ReadInt64();
//	//    multiplier = reader.ReadDecimal();
//	//    frequency = reader.ReadInt64();
//	//}
//
//	//public void Serialize(CompactWriter writer)
//	//{
//	//    writer.Write(start);
//	//    writer.Write(stop);
//	//    writer.Write(multiplier);
//	//    writer.Write(frequency);
//	//}
////C# TO JAVA CONVERTER TODO TASK: There is no preprocessor in Java:
//		///#endregion
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy