If I understand you correctly, you are asking if we can calculate running time by knowing system specs and the code in question. The answer to this is no, we cannot calculate the execution time.
The reason is that the code is not run in isolation. Those four processors are not only running your code. The operating system is doing things in the background, services are running, and so on.
In fact, not only can we not calculate the running time of the code, but we cannot even predict future running times if we already know the running time. Anything might happen during a second run of the code that could change the output. More context switches, more background tasks, or anything else.
I have experienced these effects firsthand many times when running performance tests. The same test suite will produce different timings if the computer has been sitting idle for longer, or if the last boot was a cold boot as opposed to a standby / resume, etc.
If you are asking about how to measure the running time of your code, all of the above still apply. You are talking, in essence, about running an experiment. In an experiment, all external variables must be controlled. The system must be in the same state for each run of the test, which is technically possible to achieve, but certainly far beyond the scope of this question.
The only thing we can do with any reasonable expectation of success is predict that algorithm A will perform better than algorithm B (and even that will sometimes yield unexpected results for different inputs, input sizes, etc.). We cannot predict exactly how long algorithm A will take.
Summary
Without an extremely controlled environment (beyond the scope of this question) it is impossible to calculate, estimate, or even measure the running time of an arbitrary piece of code.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…