001/*
002 *  This file is part of the Jikes RVM project (http://jikesrvm.org).
003 *
004 *  This file is licensed to You under the Eclipse Public License (EPL);
005 *  You may not use this file except in compliance with the License. You
006 *  may obtain a copy of the License at
007 *
008 *      http://www.opensource.org/licenses/eclipse-1.0.php
009 *
010 *  See the COPYRIGHT.txt file distributed with this work for information
011 *  regarding copyright ownership.
012 */
013package org.mmtk.vm;
014
015import org.vmmagic.pragma.Interruptible;
016import org.vmmagic.pragma.Uninterruptible;
017
018
019@Uninterruptible
020public abstract class Statistics {
021
022  /**
023   * Read cycle counter. This has the same semantics
024   * as {@link java.lang.System#nanoTime()}.
025   *
026   * @return current time in nanoseconds
027   */
028  public abstract long nanoTime();
029
030  /**
031   * Converts nanoseconds to milliseconds
032   *
033   * @param c time in nanoseconds
034   * @return time in milliseconds
035   */
036  public abstract double nanosToMillis(long c);
037
038  /**
039   * Converts nanoseconds to seconds
040   *
041   * @param c time in nanoseconds
042   * @return time in seconds
043   */
044  public abstract double nanosToSecs(long c);
045
046  /**
047   * Converts milliseconds to nanoseconds
048   *
049   * @param t time in milliseconds
050   * @return time in nanoseconds
051   */
052  public abstract long millisToNanos(double t);
053
054  /**
055   * Convert seconds to nanoseconds
056   *
057   * @param t time in seconds
058   * @return time in nanoseconds
059   */
060  public abstract long secsToNanos(double t);
061
062  /**
063   * Read the cycle counter
064   * @return number of cycles
065   */
066  public abstract long cycles();
067
068  /**
069   * Initializes performance events.
070   *
071   * @param events the events to initialize. This is a comma-separated
072   *  list of event names.
073   */
074  @Interruptible
075  public abstract void perfEventInit(String events);
076
077  /**
078   * Reads a performance event value.
079   *
080   * @param counter the event's id
081   * @param values a buffer that will hold the return values of the
082   * read (3 64-bit values).
083   */
084  public abstract void perfEventRead(int counter, long[] values);
085}