POV-Ray : Newsgroups : povray.off-topic : Unix shell : Re: Unix shell Server Time
3 Sep 2024 11:25:11 EDT (-0400)
  Re: Unix shell  
From: Le Forgeron
Date: 27 Jan 2011 09:05:24
Message: <4d417ba4$1@news.povray.org>
Le 27/01/2011 11:33, Invisible a écrit :
> I've got a couple of Unix questions...
> 
> 
> #1: Consider the following:
> 
>   ~$ /usr/bin/time --format="%C\n%E wall time, %P CPU, %M KB maximum"
> ./Prog1
>   ./Prog1
>   0:15.27 wall time, 89% CPU, 1608592 KB maximum
> 
> The program *actually* used about 400MB of RAM. So WTF is %M actually
> measuring? Because it sure as hell isn't "maximum resident set size of
> the process during its lifetime, measured in Kilobytes".

But there is more than 400MB of data in the RSS.
First, you have the program itself (what is the filesize ?)
Next, all the shared libraries (and their cascades).
And if 400MB is your malloc... there is also the function's stack to
allocate: calling a function with an array or a structure in C++ is
allowed, and if you do not push for a reference, you might get the value
copied on the stack...

Recursion in functions is another deepener.



> 
> (Also, why do %D, %K and %X all return 0 for every program?)

15 seconds is a very short time. Also, even if supported on the command
line, the man page states:
      "Not all resources are measured
       by all versions of Unix, so some of the values might be reported
       as zero. "

> 
> More generally, how do I make time tell me HOW MUCH RAM WAS USED?
> 

What is RAM used for ?
RSS is the answer, for program, lib & data.

> 
> 
> #2: You can compile a C++ program with
> 
>   g++ program.c++
> 
> However, for reasons beyond my comprehension, the result is always named
> "a.out". You can tediously fix this using the -o option. Alternatively,
> you can write a makefile:
> 
>   prog1: prog1.c++
>     g++ prog1.c++ -o prog1
> 
>   prog2: prog2.c++
>     g++ prog2.c++ -o prog2
> 
>   prog3: prog3.c++
>     g++ prog3.c++ -o prog3
> 
> Is there any way of automating this absurd tedium?

Yes.
Use the target naming in your makefile's rules
(have a search about $* $< $> ... in make tutorial)

-- 
Software is like dirt - it costs time and money to change it and move it
around.<br/><br/>


Just because you can't see it, it doesn't weigh anything,
and you can't drill a hole in it and stick a rivet into it doesn't mean
it's free.


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.