What is the cost of a function call?

后端 未结 15 785
天命终不由人
天命终不由人 2020-12-12 22:34

Compared to

  • Simple memory access
  • Disk access
  • Memory access on another computer(on the same network)
  • Disk access on another computer
15条回答
  •  生来不讨喜
    2020-12-12 22:52

    A function call is simply a shift of the frame pointer in memory onto the stack and addition of a new frame on top of that. The function parameters are shifted into local registers for use and the stack pointer is advanced to the new top of the stack for execution of the function.

    In comparison with time

    Function call ~ simple memory access
    Function call < Disk Access
    Function call < memory access on another computer
    Function call < disk access on another computer

提交回复
热议问题