0

I need to model the latency with several system configuration (single core, multi core, multi node on same server, multi servers) of an LTE simulator. Does anyone have any idea how to calculate the computation amount of a source code (or a part of the whole code, if I want to)? I think the possible approaches are:

  1. Take the difference in timestamp at the start and end of the execution using clock()
  2. Total no of operators/Instruction per second(machine dependent)
  3. Total no of instructions/Instruction per second

3rd is the more general version of 2nd.

The simulator is in Matlab, and I am free to use c (through Mex files).

fvrghl
  • 3,642
  • 5
  • 28
  • 36
Ankur Gautam
  • 1,412
  • 5
  • 15
  • 27
  • http://stackoverflow.com/questions/12517133/how-to-count-number-of-instructions-in-code-path – Ankur Gautam Jun 03 '13 at 22:40
  • This question was in Java. Not the same deal in c. – MatthieuBizien Jun 03 '13 at 22:46
  • Free to use C to recompile everything that you're doing in your Matlab simulator? Or free to use external C to determine 1, 2, and 3 for a Matlab program? – horchler Jun 03 '13 at 22:55
  • @oao: Matlab is JIT compiled (and relies on some Java too) so I think aspects of the linked related question (if the answers are correct) may apply. – horchler Jun 03 '13 at 22:57
  • OK, I didn't knew their were a JIT compiler in MATLAB. – MatthieuBizien Jun 03 '13 at 23:09
  • @horchler yes,basically i can use external c to access .m files for searching the operators(though it does not seems to be a proper approach)..also i can call some c function from the Matlab code which further can call some system api to get the total number of instruction executed on the processor ? or if i can get the number of operator used same time during the build in Matlab simulation . – Ankur Gautam Jun 04 '13 at 01:09

1 Answers1

2

Matlab has a very easy way to do this build in. use the following code in a script file:

tic;

operations...;

toc;

This automatically prints out the time elapsed for the set of commands used. Hope this helps

  • is it a .m file to be called from the Matlab code ? it seems from your comment that this code is to be placed in the matlab file of which number of operators is to be computed..what if the file further calls other scripts or functions ? – Ankur Gautam Jun 04 '13 at 01:12
  • you can put this just in your .m file that already has all the functions you want to test the speed of, no need to make a new function to do this test. – Curtis Eugene Maddex Jun 04 '13 at 02:17
  • can i select those variables from the matlab command screen and print in a file ? as i will need them to plot some curves – Ankur Gautam Jun 04 '13 at 05:20
  • Yes. if you say a = toc; then a gets the value of the elapsed time from tic; – Curtis Eugene Maddex Jun 04 '13 at 18:57
  • thanks a ton :) i checked it and it worked for me..but i can only get the real elapsed time during the code execution by using tic and toc..what if i want to know the total number of instructions executed on the cores ? i know both are the measure of same thing but still ..hope you get my point :) – Ankur Gautam Jun 04 '13 at 20:37
  • hmm, I do see what you are asking now, and tic;toc; answers how to calculate the latency using your first approach. But if you know the speed of your processor, and the elapsed time during your operations, then you should be able to calculate the number of operations performed. – Curtis Eugene Maddex Jun 04 '13 at 20:54
  • http://stackoverflow.com/questions/17055877/data-transferred-in-calling-a-user-defined-function can you please have a look on this question and can suggest any other idea ? – Ankur Gautam Jun 14 '13 at 21:53