Giter VIP home page Giter VIP logo

screeps-profiler's People

Contributors

gdborton avatar genhis avatar lewinke avatar riftlurker avatar sparr avatar tedivm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

screeps-profiler's Issues

Game.profiler.output() shows incorrect Avg and Ticks

I did a Game.profiler.profile(20), and then later did a Game.profiler.output() a few times. Basically, the tick counter on this output increases even though further profiling is not happening. This only affects the final summary line. Here is the summary line from two different Game.profiler.output() calls:

Avg: 9.13   Total: 246.43   Ticks: 27
Avg: 3.52   Total: 246.43   Ticks: 70

Cannot profile constructors

I can see that constructors have been blacklisted from profiling... however, I have a few classes that I would like to profile the constructor for. registerFN is not doing the trick, as it still gets blacklisted. How would I go about registering these constructors for profiling?

[Feature] Profile Section

The profiler should be able to profile a certain section of code.

Currently you would have to wrap it into a function and call that:

// some code
profiler.registerFN(() => {
	// some complex code that should get profiled
}, 'mySection') ();
// some code

Because you can't just drop-in section profiling I suggest one of the following alternatives:

// some code
const end = profiler.start('mySection');
// some complex code that should get profiled
end(); // maybe even return profiling data for this section
// some code

or

// some code
profiler.start('mySection');
// some complex code that should get profiled
profiler.end('mySection'); // maybe even return profiling data for this section
// some code

Once this is implemented it should probably also be used internally to wrap functions.

AlreadyWrappedError: Room.toString

When I use the profiler it seems to go through phases where for a few ticks, it crashes with an AlreadyWrappedError. I added a log statement, and it turns out its complaining about Room.toString. Then for subsequent ticks it will not through this error.

function already wrapped: Room.toString
[12:42:13 PM]screeps-profiler:86
  if (originalFunction.profilerWrapped) { console.log("function already wrapped:", name); throw new AlreadyWrappedError(); }
                                                                                          ^
Error
    at new AlreadyWrappedError (screeps-profiler:10:18)
    at wrapFunction (screeps-profiler:86:97)
    at profileFunction (screeps-profiler:179:10)
    at Object.getOwnPropertyNames.forEach.functionName (screeps-profiler:165:34)
    at Array.forEach (native)
    at profileObjectFunctions (screeps-profiler:124:44)
    at Profiler.prototypes.forEach.proto (screeps-profiler:117:5)
    at Array.forEach (native)
    at hookUpPrototypes (screeps-profiler:116:23)

[Question] profiler output

How to read this?
Looking at column names, I assume that calls is the number of function calls during profiling period
In what units is time measured? seconds, ms, ns?
How are those averages calculated? If you look at screenshot, it shows 887114 of calls for lookFor, but total average is 32.18, what does it mean.
I was looking for some ways of estimating CPU\RAM usage running code in training room before buying game license, how do I interpolate data from profiler into approximate usage?

image

Unable to profile es6 classes.

class Yogi {
  stealPicnicBasket() {
    // something the ranger wouldn't like.
  }
}
profiler.profileObject(Yogi.prototype, 'Yogi'); 

^ I'd expect this to properly profile the object, but it seems that es6 classes don't directly assign fields to the prototype, so you can't see them with Object.keys(Yogi.prototype). Instead you'd have to do Object.getOwnProperties(Yogi.prototype).

This should also probably result in a new api... registerClass

[Feature] Reports

Report is an object that can be created (and optionally saved) from the current profiling data.

It can be consumed by output functions (stream, email, custom).

Long term I can imagine some utility functions to compare Reports.

[Feature] Profile Memory

It's currently not possible to profile Memory deserialization cost, because the Profiler accesses (and therefor deserializes) Memory when checking if it should be profiling.

This can be solved in one of the following ways:

  • Add an option to profile Memory deserialization
  • Provide a function wrapper that doesn't check if the profiler is enabled

Profiler error

Just in case is helpful for you, this is what i get when i do Game.profiler.reset()

screeps-profiler:214
      if (currentLength + line.length + 1 < outputLengthLimit) {
                              ^
TypeError: Cannot read property 'length' of undefined
    at Object.output (screeps-profiler:214:31)
    at Object.printProfile (screeps-profiler:184:26)
    at Object.report (screeps-profiler:282:16)
    at Object.endTick (screeps-profiler:276:16)
    at Object.wrap (screeps-profiler:326:16)
    at Object.module.exports.loop (main:14:16)
    at __mainLoop:1:52
    at sigintHandlersWrap (vm.js:32:31)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.