Confused with memory/time measurements in C++/Linux

This is a discussion on Confused with memory/time measurements in C++/Linux within the Tech Board forums, part of the Community Boards category; Ok, so I have an application, where I first build a tree and then I search it. The tree has ...

  1. #1
    SAMARAS std10093's Avatar
    Join Date
    Jan 2011
    Location
    Nice, France
    Posts
    2,694

    Confused with memory/time measurements in C++/Linux

    Ok, so I have an application, where I first build a tree and then I search it. The tree has 130.000 elements and I perform 1400 queries.

    How should I measure time/memory? The second one is actually what I do not know. I am using the terminal in Linux.

    Take a look at this
    Code:
    samaras@samaras-A15:~/code/dD_spatial_drarch_NN$ /usr/bin/time -f "\n%E elapsed,\n%U user,\n%S system,\n%M memory\n%x status" ./nn
    Search for 1 NN of 1400 queries in the tree,with approximation 0.0 took 1.456464554seconds wall clock time.
    
    34:01.32 elapsed,
    2031.99 user,
    0.44 system,
    694304 memory
    0 status
    The Search for...clock time comes from my code (where I use a method named Nomimal’s animal’s (which once was a member of this forum :/) approach from here).
    However, I measure only the queries in my code.
    What is the time command actually says me? Googling confused me very much!

    Every element of the tree contains 17 doubles.

    Is the memory that's there (694304 memory) telling me how much memory does the application takes? I remember that valgrind can help, but I do not remember/know how!

    I also thought of sizeof(), but I think that's not good, since
    Code:
    myDS bla;
    bla.insert5Elements;
    sizeof(bla);
    myDs foo;
    foo.insert654735463Elements;
    sizeof(foo);
    will yield the same results.

    EDIT: I also found this # valgrind --tool=massif program

    So what is the output that time gives me? Is it enough?
    Last edited by std10093; 11-12-2013 at 07:50 AM.
    Code - functions and small libraries I use


    It’s 2014 and I still use printf() for debugging.


    "Programs must be written for people to read, and only incidentally for machines to execute. " —Harold Abelson

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    You should type "man time" into your system to find out how your specific version of time operates (it's probably the same as time(1) - Linux man page, but you never know).

    Valgrind can check your memory accesses and your allocations/deallocations, so you can see how much memory you were using over time. Only you know what that number should be (ie the log will show that you created 130000 elements in your tree, but only you (and your algorithm) know whether they needed to all be there at the same time or not).

    EDIT: You may want to look at some of the other tools of Valgrind as well, such as DHAT.
    Last edited by tabstop; 11-12-2013 at 09:02 AM.

  3. #3
    SAMARAS std10093's Avatar
    Join Date
    Jan 2011
    Location
    Nice, France
    Posts
    2,694
    Thanks for the info.
    Code - functions and small libraries I use


    It’s 2014 and I still use printf() for debugging.


    "Programs must be written for people to read, and only incidentally for machines to execute. " —Harold Abelson

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Confused Big time
    By V Ravi Prakash in forum C++ Programming
    Replies: 8
    Last Post: 08-20-2012, 01:17 AM
  2. Replies: 12
    Last Post: 12-12-2008, 12:53 PM
  3. Timing measurements on windows
    By shani in forum Windows Programming
    Replies: 16
    Last Post: 12-19-2007, 01:59 PM
  4. Confused about Memory
    By gL_nEwB in forum C++ Programming
    Replies: 22
    Last Post: 06-20-2006, 08:32 PM
  5. confused with memory allocation
    By ssharish in forum C Programming
    Replies: 2
    Last Post: 02-26-2005, 10:17 PM

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