250+ TOP MCQs on R Profiler and Answers

R Programming Language Multiple Choice Questions on “R Profiler”.

1. ________ is a systematic way to examine how much time is spent in different parts of a program.
a) Profiling
b) Monitoring
c) Logging
d) Debugging

Answer: a
Clarification: Sometimes profiling becomes necessary as a project grows and layers of code are placed on top of each other.

2. Point out the correct statement?
a) The Rprofiler() function starts the profiler in R
b) Using system.time() allows you to test certain functions or code blocks to see if they are taking excessive amounts of time
c) R must not be compiled with profiler support
d) Rprofiler() tabulates how much time is spent inside each function

Answer: b
Clarification: However, this approach assumes that you already know where the problem is and can call system.time() on it that piece of code.

3. R comes with a ________ to help you optimize your code and improve its performance.
a) debugger
b) monitor
c) browser
d) profiler

Answer: a
Clarification: In general, it’s usually a bad idea to focus on optimizing your code at the very beginning of development.

4. The _______ function computes the time (in seconds) needed to execute an expression.
a) system.timedeb()
b) system.time()
c) system.datetime()
d) system.deb()

Answer: b
Clarification: They system.time() function takes an arbitrary R expression as input and returns the amount of time taken to evaluate the expression.

5. Point out the correct statement?
a) Rprofiler() tabulates how much time is spent inside each function
b) Rprof() keeps track of the function call stack at regularly sampled intervals
c) By default, the profiler samples the function call stack every 2 seconds
d) R must not be compiled with profiler support

Answer: b
Clarification: The profiler is started by calling the Rprof() function.

6. system.time function returns an object of class _______ which contains two useful bits of information.
a) debug_time
b) proc_time
c) procedure_time
d) date.time_time

Answer: b
Clarification: if there’s an error, gives the time until the error occurred.

7. _________ time is time charged to the CPU(s) for the R expression.
a) elapsed
b) user
c) response
d) monitor

Answer: a
Clarification: Usually, the user time and elapsed time are relatively close, for straight computing tasks.

8. The elapsed time may be ________ than the user time if your machine has multiple cores/processors.
a) smaller
b) greater
c) equal to
d) null

Answer: a
Clarification: The elapsed time may be greater than the user time if the CPU spends a lot of time waiting around.

9. Parallel processing is done via __________ package can make the elapsed time smaller than the user time.
a) parallel
b) statistics
c) distributed
d) symmetry

Answer: a
Clarification: When you have multiple processors/- cores/machines working in parallel, the amount of time that the collection of CPUs spends working on a problem is the same as with a single CPU, but because they are operating in parallel, there is a savings in elapsed time.

10. You can time ________ expressions by wrapping them in curly braces within the call to system.time().
a) smaller
b) longer
c) error
d) grater

Answer: b
Clarification: If your expression is getting pretty long (more than 2 or 3 lines), it might be better to either break it into smaller pieces or to use the profiler.

Leave a Reply

Your email address will not be published. Required fields are marked *