Skip to content

Commit

Permalink
Add native proc profiling
Browse files Browse the repository at this point in the history
  • Loading branch information
amylizzle committed Dec 8, 2024
1 parent ca18c19 commit c9f8c51
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
5 changes: 4 additions & 1 deletion OpenDreamRuntime/DreamThread.cs
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,10 @@ public static DreamValue Run(DreamProc proc, DreamObject src, DreamObject? usr,
var context = new DreamThread(proc.ToString());

if (proc is NativeProc nativeProc) {
return nativeProc.Call(context, src, usr, new(arguments));
var zone = Profiler.BeginZone(filePath:"Native Proc", lineNumber:0, memberName:nativeProc.Name);

Check warning

Code scanning / InspectCode

Explicit argument passed to parameter with caller info attribute Warning

Explicit argument passed to parameter with caller info attribute

Check warning

Code scanning / InspectCode

Explicit argument passed to parameter with caller info attribute Warning

Explicit argument passed to parameter with caller info attribute
var result = nativeProc.Call(context, src, usr, new(arguments));
zone?.Dispose();
return result;
}

var state = proc.CreateState(context, src, usr, new DreamProcArguments(arguments));
Expand Down
2 changes: 1 addition & 1 deletion OpenDreamRuntime/Procs/AsyncNativeProc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public sealed class State : ProcState {
private AsyncNativeProc? _proc;
public override DreamProc? Proc => _proc;

public override (string SourceFile, int Line) TracyLocationId => ("Native Proc", 0);
public override (string SourceFile, int Line) TracyLocationId => ("Async Native Proc", 0);

private Func<State, Task<DreamValue>> _taskFunc;
private Task? _task;
Expand Down
2 changes: 2 additions & 0 deletions OpenDreamRuntime/Procs/DMProc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,9 @@ public void SetReturn(DreamValue value) {
public ProcStatus Call(DreamProc proc, DreamObject? src, DreamProcArguments arguments) {
if (proc is NativeProc p) {
// Skip a whole song and dance.
var zone = Profiler.BeginZone(filePath:"Native Proc", lineNumber:0, memberName:p.Name);

Check warning

Code scanning / InspectCode

Explicit argument passed to parameter with caller info attribute Warning

Explicit argument passed to parameter with caller info attribute

Check warning

Code scanning / InspectCode

Explicit argument passed to parameter with caller info attribute Warning

Explicit argument passed to parameter with caller info attribute
Push(p.Call(Thread, src, Usr, arguments));
zone?.Dispose();
return ProcStatus.Continue;
}

Expand Down

0 comments on commit c9f8c51

Please sign in to comment.