Navigation

    forum

    • Login
    • Search
    • Categories
    • Recent
    • Popular
    • Users
    • Groups
    1. Home
    2. rowan-bara
    • Flag Profile
    • block_user
    • Profile
    • Following
    • Followers
    • Topics
    • Posts
    • Groups
    • Blog

    rowan-bara

    @rowan-bara

    1
    Posts
    617
    Profile views
    0
    Followers
    0
    Following
    Joined Last Online

    rowan-bara Follow

    Posts made by rowan-bara

    • Easily solvable memory parsing inefficency

      I have been experimenting with the Memory object for awhile. I decided to modify the JSON.parse and JSON.stringify method to see when Screeps was parsing and stringifying Memory:

      let stringify = JSON.stringify;
      JSON.stringify = (object) => {
        if(object === Memory) {
          console.log("stringifyed Memory");
        }
        return stringify(object);
      };
      let parse = JSON.parse;
      JSON.parse = (string) => {
        //closest way to checking if the string being parsed is Memory. 
        //should work for any Memory that is correctly formatted.
        if(parse(string).creeps) {
          console.log("parsed Memory");
        }
        return parse(string);
      }
      module.exports.loop = function () {
        //Memory is referenced to cause Screeps to perceve memory as active
        Memory;
      }
      

      each tick the probe code posts this to the console:

      [shard3] parsed Memory
      [shard3] stringifyed Memory
      

      Business as normal right? Here is the issue: variables can be loaded before the game loop on startup. There is no reason Screeps should parse the Memory each tick. Memory could be parsed before the game loop, then stringifyed each tick. it would get the job done without as much overhead.

      Is there any reason that the Memory has to be parsed each tick? If so I would be curious to know why.

      posted in Technical Issues and Bugs
      rowan-bara