0

I've tried everything to get the microtime in Flash using the sampler class but to no avail. Here is my code so far:

import flash.sampler.Sample;
import flash.sampler.getLexicalScopes;
import flash.sampler.getMemberNames;
import flash.sampler.getSampleCount;
import flash.sampler.getSamples;
import flash.sampler.getSize;
import flash.sampler.startSampling;
import flash.sampler.stopSampling;

private function init():void {

    startSampling();

    var x:String = "Hello world";

    stopSampling();

    var samples:Object = getSamples();
    var sampleCount:int = getSampleCount(); // 0
}

Here is the Sampler and SamplerScript extensions classes. It is calling setconst_time to get the time. It may also be calling another method:

uint64_t Sampler::nowMicros()
{
    return GC::ticksToMicros(VMPI_getPerformanceCounter());
}

As seen in Sampler core class.

I was hoping there was a getMicroTime() method (see getTimer()) but there is not. So I was trying to create samples before and after a code block. Calling getSamples should return an array of Sample objects. Each Sample instance should has a sample.time property with the time in micro seconds. But, using the code above, no samples are taken. The sample count is zero.

1.21 gigawatts
  • 16,517
  • 32
  • 123
  • 231
  • 1
    "*but to no avail*" so what happens exactly? What are you expecting? – null Oct 23 '16 at 12:19
  • I've updated the post – 1.21 gigawatts Oct 23 '16 at 12:28
  • 1
    Have you tried doing anything reasonable between start and stop? You're assigning a constant value to a variable. Chances are the compiler moves this away or it really doesn't take up any time measurable by those classes. – null Oct 23 '16 at 15:46
  • I called `startSampling()` at initialize instead. Nothing has changed. Do you think that the Advanced Telemetry flag has to be set? I'm using Apache Flex 4.15. I've heard that has telemetry enabled by default. Note: Even if I get this to work by enabling telemetry I don't think the sampler classes work in the release build meaning... that there is still a need for getMicrotime() call. – 1.21 gigawatts Oct 25 '16 at 16:09

0 Answers0