main :: () {
   r: *rmt.Remotery;

   err := rmt.CreateGlobalInstance(*r);
   assert(err == .NONE, "%", err);
   defer rmt.DestroyGlobalInstance(r);

   rmt.LogText("start profile");
   for 0..100 {
      delay();
      sleep_milliseconds(100);
   }
   rmt.LogText("end profile");
}

delay :: () {
   rmt.BeginCPUSample("delay", 0, null);
   defer rmt.EndCPUSample();

   j := 0.0;
   for 0..1000 {
      j += sin(it.(float32));
   }

   recurse();
   aggregate();
   aggregate();
   aggregate();
}

recurse :: (depth := 0) {
   rmt.BeginCPUSample("recurse", xx rmt.SampleFlags.Recursive, null);
   defer rmt.EndCPUSample();

   sleep_milliseconds(100);

   if depth < 5 {
      recurse(depth + 1);
   }
}

aggregate :: () {
   rmt.BeginCPUSample("aggregate", xx rmt.SampleFlags.Aggregate, null);
   rmt.EndCPUSample();
}

#import "Math";
#import "Basic";

rmt :: #import,file "../module.jai";
