Question:

Does print() cost CPU cycles?

James: 23 May 2022

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());

Answer:
Benjamin: 23 May 2022

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");
}