Yes and no, GNU time tries to show the summary/peak of everything.
You may check that using a small C program, say mal.c:
#include <stdlib.h>
#include <string.h>
int main(int argc, char **argv)
{
long bytes;
void *buf;
bytes = atol(argv[1]) * 1024;
buf = malloc(bytes);
memset(buf, 0, bytes);
printf("");
return 0;
}
And see:
$ gcc mal.c -o mal
$ /usr/bin/time -f "%M" sh -c "./mal 5000"
5452
$ /usr/bin/time -f "%M" sh -c "./mal 10000"
10452
$ /usr/bin/time -f "%M" sh -c "./mal 5000; ./mal 10000"
10452
But as mentioned in the getrusage(2) man page (Linux), this is the max RSS of any single child process, not the instantaneous cumulative RSS of a tree of processes, all simultaneously using memory
In other words it does not summarize parallel or background processes, as you can see:
$ /usr/bin/time -f "%M" sh -c "./mal 1000000 & ./mal 5000"
5452
This also implies that you need to run time inside of your screen session to measure $CMD and not only screen.
FYI the difference between the shell built-in is that the time binary can't directly summarize pipes or functions:
$ time /bin/sleep 1 | /bin/sleep 2
real 2.00
user 0.00
sys 0.00
$ /usr/bin/time -p /bin/sleep 1 | /bin/sleep 2
real 1.00
user 0.00
sys 0.00
timewill only give information for its children, and by stuffing a command into an existing screen session, that command will not be a child of your script, so will not be observed bytime. You might use anothertimewhen you start the screen session, but note that it only gives the max RSS of the biggest process.