High CPU usage of Game.market.getAllOrders()
Maey last edited by
I've noticed a call to Game.market.getAllOrders() takes around 4-5 CPU to execute, on shard0.
Perhaps a function call to get only certain orders (by resource, or type, or resource+type), or only a certain number of orders, rather than applying a filter to all orders would be faster?
There actually is a filter option for that, while it does mention the lodash.filter method, IIRC, its cached and faster. https://docs.screeps.com/api/#Game.market.getAllOrders
Mototroller last edited by
@maey, there was an official announcement about indexing and caching.
Yep, plain (not-a-callback-like) filter will work much faster.
Definitely strange it isn't mentioned in documentation
deft-code last edited by
This post is deleted!
Maey last edited by Maey
@Mototroller I'll give that a try, thanks for the info. It would definitely be useful if the documentation included the text at that announcement link.
Edit: Yeah, that's much better, now taking around 0.3 CPU-units for a run.