2

Does eosio::print cost CPU cycles to execute on the BPs? On my node I have an option to print. Assuming it is disabled for the BPs (print defined to return; or similar), does evaluating the arguments cost CPU cycles, e.g.

print("Hi", expensiveFunction());
2

print() appears to cost CPU cycles and expensiveFunction() is evaluated. I tried with the following. As there is no sleep I just looped (the expensive function takes about 50 ms > 30 ms allowed on the test node). This results in Error 3080006: Transaction took too long

string expensiveFunction()
{
  int volatile i = 0;
  for(; i<600000;)
    {
      i++;
    }
  return to_string(i);
}

ACTION performance::testprint()
{
  print("start");
  print("hi", expensiveFunction());
  print("stop");
}
  • We decided to avoid this by putting a macro around the print commands like D(print(...);). The macro looks like this #define DEBUG 0 #if DEBUG #define D(x) x #else #define D(x) #endif – colin Dec 20 '18 at 18:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for?Browse other questions tagged or ask your own question.