Exemple #1
0
	/**
	 * Open the probe with the specified name and measures
	 * the time value at that point in the program's path
	 * of execution.
	 *
	 * If a probe for that name already exists, this method
	 * does nothing.
	 */
	void openProbe(string s)
	{
		TimeProbe* tp;

		if (probes[s] == 0)
		{
			tp = new TimeProbe();
			probes[s] = tp;
		}
		else
		{
			tp = probes[s];
		}
		if (tp->getStatus() != TimeProbe::INACTIVE)
			return;

		tp->setStatus(TimeProbe::OPEN);

		timeval* tv = new timeval();
		struct timezone tz;

		gettimeofday(tv, &tz);
		tp->setStart(tv);

	}
Exemple #2
0
	/**
	 * Closes the probe for the given name. If the probe
	 * is not open or if the probe is already closed this
	 * method does nothing.
	 */
	void closeProbe(string s)
	{

		TimeProbe* tp;
		if (probes[s] == 0)
			return;

		tp = probes[s];

		if (tp->getStatus() != TimeProbe::OPEN)
			return;

		timeval* tv = new timeval();
		struct timezone tz;
		gettimeofday(tv, NULL);
		tp->setEnd(tv);

		tp->setStatus(TimeProbe::CLOSED);

	}