/***************************************************************************
 *                                                                         *
 *   LinuxSampler - modular, streaming capable sampler                     *
 *                                                                         *
 *   Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck   *
 *                                                                         *
 *   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 2 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, write to the Free Software           *
 *   Foundation, Inc., 59 Temple Place, Suite 330, Boston,                 *
 *   MA  02111-1307  USA                                                   *
 ***************************************************************************/

#ifndef __LS_GIG_PROFILER_H__
#define __LS_GIG_PROFILER_H__

#include <stdio.h>

#include "../../common/global.h"
#include "../../common/RTMath.h"

namespace LinuxSampler { namespace gig {

    /** @brief Synthesis Profiler
     *
     * Provides a benchmark algorithm to return a somewhat abstract Bogo
     * Voices value to reflect the voice count limit of the running system
     * with the given instrument patch und circumstances. Note that the
     * real voice count limitation will in practice be lower than this Bogo
     * Voice value.
     */
    class Profiler {
        public:
		static void Reset();

		static void enable();

		static bool isEnabled() {
		    return bEnabled;
		}

	    static unsigned int GetBogoVoices( unsigned int SamplingFreq );

	    static RTMath::time_stamp_t Stamp( void )
	    {
                    return RTMath::CreateTimeStamp();
	    }

	    static void Record( RTMath::time_stamp_t start,
			unsigned int samples, unsigned int skip )
	    {
		    RTMath::time_stamp_t stop = Stamp();
		    profilingTime += (stop - start);
		    profilingSamples += (samples - skip);
	    }

	    static void Calibrate( void );

	private:
	    static unsigned long long profilingSamples;
	    static unsigned long long profilingTime;
	    static double tsPerSecond;
	    static bool bEnabled;
    };

}} // namespace LinuxSampler::gig

#endif // __LS_GIG_PROFILER_H__
