R Programming Questions and Answers – R Profiler – 1

This set of R Programming Language Multiple Choice Questions & Answers (MCQs) focuses on “R Profiler – 1”.

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
View Answer

Answer: a
Explanation: 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
View Answer

Answer: b
Explanation: 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
View Answer

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

advertisement
advertisement

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()
View Answer

Answer: b
Explanation: 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
View Answer

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

Sanfoundry Certification Contest of the Month is Live. 100+ Subjects. Participate Now!

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
View Answer

Answer: b
Explanation: 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
View Answer

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

advertisement

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
View Answer

Answer: a
Explanation: 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
View Answer

Answer: a
Explanation: 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.
advertisement

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
View Answer

Answer: b
Explanation: 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.

Sanfoundry Global Education & Learning Series – R Programming Language.

Here’s the list of Best Books in R Programming Language.

To practice all areas of R Programming Language, Here is complete set of 1000+ Multiple Choice Questions and Answers.

If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.