SSD6 Multiple-Choice Quiz 4

【ssd6 quiz 4 做了6次 】

 

     

      

        

 

1.To quickly allocate and free many variables of a commonly used data type, we could  
 (a) minimize the size of the data type.
 (b) coalesce blocks when they are freed.
 (c) use sizes which are powers of two.
 (d) keep a linked list of free objects of that type's size.

Correct answer is  (d)
 
2."CPU time" measures  
 (a) the percentage utilization of the CPU by the system.
 (b) the time spent executing system functions.
 (c) the time spent by a program executing program instructions.
 (d) wall time

Correct answer is  (c)
 
3.Which of the following are useful for observing program performance?
I. Direct measurement with a stopwatch.
II. Statistical Sampling.
III. System Monitors
 
 (a) I, II, and III
 (b) I and III only
 (c) I and II only
 (d) II and III only

Correct answer is  (a)
 
4.Amdahl's law, applied to program optimization, says that  
 (a) algorithmic design is more important than code quality for performance
 (b) program measurement is a prerequisite to optimization
 (c) each optimization about doubles a program's performance
 (d) successive program optimizations tend to produce diminishing returns
Correct answer is  (d)
 

2."Wall time" measures  
 (a) the total duration of a program's execution.
 (b) idle time.
 (c) the user time plus the system time.
 (d) the time a program spends waiting for input and output.

Correct answer is  (a)
 
3.Which of the following are advantages of using statistical sampling to profile programs?
I. Exact run times of all functions can be determined.
II. Code can be instrumented automatically.
III. The performance impact due to measurement can be minimal.
 
 (a) I and III only
 (b) II and III only
 (c) I and II only
 (d) I, II, and III

Correct answer is  (b)
 

4.Which of the following is likely to offer the best performance improvement for programs that spend 50% of their time comparing strings?  
 (a) Be sure to use hardware string-comparison instructions.
 (b) Call a library function for string comparison.
 (c) Store strings uniquely so that pointer comparison can be used.
 (d) Write in-line code for string comparison to eliminate a procedure call.
Correct answer is  (c)

 

1.A memory pool is a large block of memory from which small objects are allocated piecemeal by breaking them off from the pool as required. Under which of the following conditions would such a scheme result in greatly improved performance?
I. All objects allocated from the pool are freed at around the same time.
II. All objects allocated from the pool are of similar sizes.
III. A garbage collector takes care of freeing memory.
 
 (a) II only.
 (b) I only.
 (c) I and II only.
 (d) III only.

Correct answer is  (b)

上一篇:两段代码 老师给的


下一篇:This virtual machine appears to be in use