Monitor times spent in a matrix

This is a discussion on Monitor times spent in a matrix within the C++ Programming forums, part of the General Programming Boards category; I have homework, 2 parts 1. Initialize 2 square arrays (dynamically), then multiple them and save the result in third ...

  1. #1
    Registered User
    Join Date
    Mar 2006
    Posts
    5

    Smile Monitor times spent in a matrix

    I have homework, 2 parts

    1. Initialize 2 square arrays (dynamically), then multiple them and save the result in third array. (I have done this part using list queue)

    2. Monitor times spent in the matrix multiplication part. ??????
    (i need this part)

    Then test the code many times each time with different array size and monitor the time, so i can analyze the multiplication time as a function of array size.

    Am working on windows xp / C++
    I need time in microseconds


    Thz
    Last edited by Rajaa; 03-18-2006 at 01:30 PM.

  2. #2
    Supermassive black hole cboard_member's Avatar
    Join Date
    Jul 2005
    Posts
    1,709
    Quote Originally Posted by Rajaa
    I have homework, 2 parts

    1. Initialize 2 square arrays (dynamically), then multiple them and save the result in third array. (I have done this part using list queue)

    2. Monitor times spent in the matrix multiplication part.

    Then test the code many times each time with different array size and monitor the time, so i can analyze the multiplication time as a function of array size.

    Thz
    Nice. What do you want us to do about it?
    Good class architecture is not like a Swiss Army Knife; it should be more like a well balanced throwing knife.

    - Mike McShaffry

  3. #3
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,673
    So which OS/Compiler are you using?

    What sort of time resolution are you looking for - microseconds? weeks?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  4. #4
    Registered User
    Join Date
    Mar 2006
    Posts
    5
    .....
    Last edited by Rajaa; 03-18-2006 at 02:50 PM.

  5. #5
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,673
    > Am working on windows xp / C++
    C++ is the language
    A compiler is like vs.net, dev-c++, borland 5.5

    Anyway, just google your way through
    http://www.google.co.uk/search?hs=p8...G=Search&meta=
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  6. #6
    Registered User
    Join Date
    Mar 2006
    Posts
    5

    How can I do it using Linux?

    Someone told me it is easier to solve this problem using Linux (He forget the correct command ) , dose anyone know How can I do that? ????

    Rajaa

  7. #7
    Registered User
    Join Date
    Mar 2006
    Posts
    725
    --double post--
    Last edited by jafet; 03-19-2006 at 03:36 AM.

  8. #8
    Registered User
    Join Date
    Mar 2006
    Posts
    725
    Alright everybody, I did it for him

    Code:
    /**
    int[] test(int ntimes)
    
    test() will run int mul_mat(int nsize) which should do a test on a matrix with size nsize,
    the implementation is up to you. mul_mat() should always return 1 under normal operation.
    
    It will run mul_mat() with increasing sizes of nsize, from 1 to ntimes, then time the results and return them
    as an array of ints in microseconds.
    **/
    
    #include <ctime>
    #include <windows.h>
    int*test(int god){int lll,ll1[god],l1l=time(0);Sleep(INT_MAX/2097152);l1l=time(0)-l1l;while(god--)ll1[god]=1000000*(clock()-mul_mat(god)+1-clock()/l1l);}

  9. #9
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,673
    > Someone told me it is easier to solve this problem using Linux
    Yes, its
    time myprog
    But it's not microseconds like you asked.
    It also times the process, not an individual function.

    Read the link I posted if you want to read the high resolution clock in windows.

    > .....
    Please don't edit your post after replies to make those replies seem non-sensical.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  10. #10
    Registered User
    Join Date
    Mar 2006
    Posts
    5
    Thanks jafet

    I execute your code I get this error. : ‘test’: local function definitions are illegal. For this line [ int lll,ll1[god],l1l=time(0); ] , what shall I do??

  11. #11
    Registered User
    Join Date
    Mar 2006
    Posts
    5
    Thanks Salem

    There is no link!! Can u post it again.

  12. #12
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,673
    Just this once....
    click me
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C - access violation
    By uber in forum C Programming
    Replies: 2
    Last Post: 07-08-2009, 01:30 PM
  2. Matrix Help
    By HelpmeMark in forum C++ Programming
    Replies: 27
    Last Post: 03-06-2008, 04:57 PM
  3. What is a matrix's purpose in OpenGL
    By jimboob in forum Game Programming
    Replies: 5
    Last Post: 11-13-2004, 11:19 PM
  4. Matrix and vector operations on computers
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 11
    Last Post: 05-11-2004, 06:36 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21