Advertisement

During LineCallback, GetLineNumber() is returning 0 for line number

Started by June 20, 2020 06:52 PM
2 comments, last by jsd1982 4 years, 5 months ago

As the title says, during a LineCallback when calling GetLineNumber() on the context, it's returning 0 for a line number while filling in the section with a legitimate section name. I suspect this is a constructor call for the script class contained in the script section it references. Is there a way to know for sure whether this represents execution inside a script class constructor? It'd be great if script class constructors had actual line numbers represented by GetLineNumber().

For context, I've built a simple sampling profiler that uses the LineCallback to collect the last executed section/line as the sample to record which is picked up by separate thread that records the last sampled location at a regular interval (100 microseconds). This way I get more sample hits on script lines which call host functions which take more time to execute than ordinary script lines which don't interact with the host.

Anyway, using this profiler I've identified a particular script section with line 0 as a hot path and would like to optimize it but I'm unsure whether line 0 represents execution in a constructor or something else entirely.

Thanks!

Line number 0 is usually for the auto generated code, i.e. is not directly represented by any script line, for example factory functions.

In your profiler, do you also show the call stack? I.e. how the script reached the point of the sample? That would be valuable information for figuring out how to optimize the code, and would likely tell you a little bit more about the line number 0, as you would see from where the code is called.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

Advertisement

Ah that makes a lot of sense. It's probably the factory function for the script class then. Regardless, I optimized that away by preallocating an array<Class@> of all the instances I need.

No I don't currently pull the rest of the call stack in the profiler but that's a great idea and I can certainly do that. It's been good enough for me to just sample the top of the stack so far. Fixed a lot of performance issues that way.

Thanks!

This topic is closed to new replies.

Advertisement