The time function can always be used externally to
measure performance but has limitted accuracy of around 1
millisecond.
Internally there are precise clock routines that can be used to
measure the performance of each part of a code. These are different for
each programming language, but the use is always the same.
Scaling studies can help determine how many cores or nodes we can
efficiently use for a parallel job of a given problem size.
Measuring memory use can be done from outside a program, but you may
also be able to calculate total memory for simple programs.