@@ -4640,11 +4640,36 @@ declare namespace Cloak {
46404640 function hasFileDescriptor ( fd : number ) : boolean ;
46414641}
46424642
4643+ /**
4644+ * Simple worst-case profiler built on top of Interceptor.
4645+ *
4646+ * Unlike a conventional profiler, which samples call stacks at a certain
4647+ * frequency, you decide the exact functions that you're interested in
4648+ * profiling.
4649+ *
4650+ * When any of those functions gets called, the profiler grabs a sample on
4651+ * entry, and another one upon return. It then subtracts the two, to compute how
4652+ * expensive the call was. If the resulting value is greater than what it's seen
4653+ * previously for the specific function, that value becomes its new worst-case.
4654+ *
4655+ * Whenever a new worst-case has been discovered, it isn't necessarily enough to
4656+ * know that most of the time/cycles/etc. was spent by a specific function. That
4657+ * function may only be slow with certain input arguments, for example.
4658+ *
4659+ * This is a situation where you can pass in `ProfilerInstrumentCallbacks` to
4660+ * implement a `describe()` callback for the specific function. Your callback
4661+ * should capture relevant context from the argument list and/or other state,
4662+ * and return a string that describes the new worst-case that was just
4663+ * discovered.
4664+ *
4665+ * When you later decide to call `generateReport()`, you'll find your computed
4666+ * descriptions embedded in each worst-case entry.
4667+ */
46434668declare class Profiler {
46444669 /**
46454670 * Starts instrumenting the specified function using the specified sampler.
46464671 */
4647- instrument ( functionAddress : NativePointerValue , sampler : Sampler , callbacks : ProfilerInstrumentCallbacks ) : void ;
4672+ instrument ( functionAddress : NativePointerValue , sampler : Sampler , callbacks ? : ProfilerInstrumentCallbacks ) : void ;
46484673
46494674 /**
46504675 * Generates an XML report from the live profiler state. May be called at
0 commit comments