3 Pages

proj2-soln

Course: CS 360, Fall 2009
School: Hendrix
Rating:
 
 
 
 
 

Word Count: 1625

Document Preview

language Evaluating efciency Carl Burch, CSCI 360 December 11, 2004 I was generally disappointed with the efciency of the programs students benchmarked for the project, which made it difcult to evaluate results. After looking over programs and papers, I decided to complete the assignment myself and generate an example solution. I drew some of the ideas for test problems from students ideas, but I ended up...

Register Now

Unformatted Document Excerpt

Coursehero >> Arkansas >> Hendrix >> CS 360

Course Hero has millions of student submitted documents similar to the one
below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.

Course Hero has millions of student submitted documents similar to the one below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.
language Evaluating efciency Carl Burch, CSCI 360 December 11, 2004 I was generally disappointed with the efciency of the programs students benchmarked for the project, which made it difcult to evaluate results. After looking over programs and papers, I decided to complete the assignment myself and generate an example solution. I drew some of the ideas for test problems from students ideas, but I ended up implementing all of the programs from scratch. Programmers say it all the time: I dont think language X is a good choice because its not fast enough. Wise programmers understand that computation speed is a minor programming consideration far more often than many computing enthusiasts would like to admit, the major issue is programmer time (i.e., cost). Even when speed is important, the major bottleneck is often an issue over which the language is nearly irrelevant, such as rendering hardware, or disk speed, or virtual memory usage. But, still, we cant deny that sometimes the speed of a language really does matter. And for that reason, weve put together a benchmark suite comparing the performance of ve languages: C Programmers widely acknowledge that good C programming is nearly unbeatable, so this is the baseline for the benchmarking. Representing C is GNUs gcc compiler (version 3.3.2), using the -O3 option. Java Most usage of Java bears a signicant efciency burden in terms of the virtual machine that interprets the compiled byte code, so most programmers understand that Java is quite a bit slower. They dont typically have a good handle on how much slower, but they suspect its a fair amount. We used Suns JDK 5.0 to represent Java, using the -O option for compiling. Haskell This obscure language represents a peculiar corner of the programming language world called functional languages. One of the peculiar things about such languages is that they dont have variables. Although Haskell isnt widely known among programmers, those who know of functional languages suspect that they, too, are rather slow. We used the ghc Haskell compiler (version 6.2.2), using the -O option, which generates machine code (using C and gcc as an intermediate language). Perl One of the most widely used scripting languages out there, Perl is an interpreted, which can affect its run-time dramatically. We used Larry Walls perl program (version 5.8.3). Python This upstart interpreted language is becoming a popular rival to Perl. We used Guido van Rossums Python 2.3.3 Its not entirely fair to use a single language system as the representative for each language, since some may be optimized more completely than others. But in each case, we selected one of the most popular systems for executing those programs; it stands to reason that the most popular system would receive the greatest work on being able to execute programs in that language efciently. Conventional wisdom would hold that C would be fastest among these, that Java would be second but still several times slower, and the others would fall far away behind that, probably near the same spot generally. We used a benchmark suite of ve problems, representing different categories of problems. Because language efciency is important primarily for computational problems, all ve problems are computational in nature. 1 Harm This simple test represents a problem involving a lot of oating-point computations. In this, we determined which is the rst harmonic number that is more than 15. The nth harmonic number is the sum of the recipricals of the numbers from 1 to n; for example, the second harmonic number is 1.5 1 (1 + 1 ), while the sixth is 2.45 (1 + 1 + 1 + 4 + 1 + 1 ). Despite a fairly quick start, they grow very 2 2 3 5 6 slowly, and in fact they dont reach 15 until the 1,835,422nd harmonic number. Sieve This test represents the eld of problems involving heavy integer arithmetic. For it, we determine the number of primes up to 500,000, using Eratosthenes sieve. This algorithm involves rst creating a list of the numbers in question and then, starting with the rst one (which will be 2), knocking out all the multiples of that, then knocking out all the multiples of the next one remaining, then of the next one remaining, until we reach the square root of 200,000. As a functional language, Haskell cant provide a good implementation for this algorithm, so after some experimentation with different methods, we settled on an algorithm that would rst nd the primes up to the square root of 200,000 (using a recursive call) and then add on all the numbers beyond the square root for which none of those primes are a factor. Pack In this problem, we have a set of 25 numbers chosen randomly from 0 and 1, and we are to determine the set with the largest sum but not exceeding 6. This is an NP-complete problem, and the algorithm used was an exhaustive search approach. The algorithm implemented used pruning techniques to reduce the size of the search. Just Here, we want determine to the best way to introduce line breaks into a left-justied paragraph, namely a single paragraph containing the nearly 73,000 words of Hamlet. Though the best line breaks is a subjective question, we used the traditional technique of quantifying the badness of a set of line breaks by rst computing for each line the size of the empty gap between the right edge of that line to the right edge of the paper, and then computing the sum of the squares of these gaps sizes. Computing the badness can be done efciently via a dynamic programming algorithm. (This program, by the way, was the most input-intensive of the bunch.) Dups This test represents programs that use string manipulation heavily. Each program took a le containing the rst 4,000 words of Hamlet and counted how many distinct words it contained. The algorithm used to remove duplicate words began with the rst word, crossing out all following duplicates; then if the second word was not already crossed out, it crossed out all the following duplicates of that one; and so on. Later, it counted how many words were left. We implemented each of these problems in the ve tested languages. We tried to implement them as efciently as possible in each target language, but of course, we could probably trim off the times for all the languages with a more dedicated effort. The general rule here is that we tried not to spend a lot of our time on any single language, so that the total development time was spread relatively evenly. To collect times, we ran each program seven times, discarded the slowest and fastest times, and averaged the remaining ve together. All tests were performed on Linux computer (running Mandrake 10.0) containing a single low-power 1MHz VIA C3 processor. Figure 1 summarizes the results. The conventional wisdom held in its broadest characteristics: C is indeed the fastest among those tested, with Java behind it, and the others behind both of those. But there are also some surprises. If forced to guess how much slower Java is than C, many programmers would guess that it is several times maybe a factor of ve. For our tests, though, we found that it was only two. Of course, thats still not as good as one might hope: It takes twice as long to do the same thing. 2 problem Harm Sieve Pack Just Dups Average raw C time (ms) 0.24 0.11 0.27 0.09 0.44 C 1.00 1.00 1.00 1.00 1.00 1.00 Java 1.58 2.00 1.54 2.63 2.07 1.97 Haskell 1.71 8.91 2.43 14.67 0.68 5.68 Perl 18.12 25.47 58.81 56.48 17.48 35.27 Python 30.96 44.28 36.58 91.61 21.50 44.99 (All values below the line are in multiples of the C baseline.) Figure 1: Results for all languages and problems. Looking at the overall performance, Haskell seems to do signicantly worse than Java. But when we look at the numbers harder, we can see that this was due largely to very poor performance on the the Sieve and Just problems, where the algorithm used didnt map onto the language well. On the other problems, it did qui...

Textbooks related to the document above:
Find millions of documents on Course Hero - Study Guides, Lecture Notes, Reference Materials, Practice Exams and more. Course Hero has millions of course specific materials providing students with the best way to expand their education.

Below is a small sample set of documents:

Hendrix - CS - 360
Midterm, CSCI 360, Fall 2004Name: 1. [10 pts] Using BNF notation, describe a context-free grammar for the language of strings consisting of a sequence of as, followed by bs, followed by cs, in which there are as many cs as there are as and bs put to
Hendrix - CS - 490
Questions 1 Question Midterm1: (Solution, p 2) Explain a reason why the painters algorithm for handling occlusion, in which objects are drawn starting from the farthest away, does not work well for general 3D rendering. Question Midterm2: (Solution,
Hendrix - ASSN - 4
CSci 490, Spring 2005, Assignment 4This assignment, worth 40 points, is due at 3pm, Friday, February 18. Submit it by attaching your modied les to an e-mail to cburch@cburch.com. Your job in this assignment is to write a program using OpenGL that ge
Hendrix - ASSN - 490
CSci 490, Spring 2005, Assignment 4This assignment, worth 40 points, is due at 3pm, Friday, February 18. Submit it by attaching your modied les to an e-mail to cburch@cburch.com. Your job in this assignment is to write a program using OpenGL that ge
Hendrix - ASSN - 490
CSci 490, Spring 2005, Assignment 5This assignment, worth 50 points, is due at 3pm, Friday, March 4. Submit it by attaching your modied les to an e-mail to cburch@cburch.com. In Assignment 3, you modied a Java graphics system that drew wire-frame dr
Hendrix - ASSN - 490
CSci 490, Spring 2005, Assignment 7This assignment, worth 40 points, is due at 3pm, Friday, April 29. Submit it by attaching your modied les to an e-mail to cburch@cburch.com. From the Web page, you can download a simple OpenGL program that uses a p
Hendrix - ASSN - 7
CSci 490, Spring 2005, Assignment 7This assignment, worth 40 points, is due at 3pm, Friday, April 29. Submit it by attaching your modied les to an e-mail to cburch@cburch.com. From the Web page, you can download a simple OpenGL program that uses a p
Hendrix - CS - 490
Quiz 1, CSci 490, Spring 2005Name: 1. [6 pts] Suppose we are performing a perspective projection onto a vertical screen one foot square which is two feet away from the eye. Forty feet away in the same direction, there is a wall ten feet high. If the
Hendrix - CS - 490
CSci 490, Spring 2005, Quiz 3Name: 1. [7 pts] Explain the goal motivating Gouraud shading (i.e., the reason for it), and describe the technique that it involves.2. [7 pts] Outline the compression algorithm used for the PNG image format.3. [8 pts
Hendrix - CS - 490
Questions 1 Question Q11: (Solution, p 2) How is it that nearly any light frequency distribution can be represented exactly using a combination of only three particular light frequencies (red, green, blue)? Question Q12: (Solution, p 2) In terms of t
Hendrix - CS - 490
CSci 490, Spring 2005, MidtermName: 1. [7 pts] Distinguish between the terms raster graphics and vector graphics, and for each, give a specic example of graphical system using it.2. [8 pts] Explain what the homogeneous coordinate system are, and e
Hendrix - CS - 490
Solutions, CSci 490, Spring 2005, Quiz 31. Curved surfaces are most easily represented in most systems with a polygon approximation, but rendering the polygon surfaces shows sharp shading differences if the polygons are relatively large, destroying
Hendrix - CS - 490
Solutions, Quiz 1, CSci 490, Spring 20051. 100 pixels. [The projection of the wall onto the screen would be 1/2 a foot, since the distance:height ratio would be the same both for the wall (40:10) and for the projection of the wall onto the screen (2
Hendrix - CS - 490
CSci 490, Spring 2005, Quiz 1Name: 1. [6 pts] Suppose we are performing a perspective projection onto a vertical screen one foot square which is one foot away from the eye. Eighty feet away in the same direction, there is a wall ten feet high. If th
Hendrix - CS - 490
Questions 1 Question Q21: (Solution, p 2) What is the motivation behind generalizing homogeneous coordinates to allow the last entry to be other than 1? Question Q22: (Solution, p 2) Explain the concept of Gouraud shading. Question Q23: (Solution, p
Hendrix - ASSN - 490
CSci 490, Spring 2005, Assignment 1This assignment, worth 40 points, is due at 3pm, Friday, January 28. Submit it by attaching your modied les to an e-mail to cburch@cburch.com. This assignment involves writing two important pieces to a rather sophi
Hendrix - ASSN - 490
CSci 490, Spring 2005, Assignment 3This assignment, worth 30 points, is due at 3pm, Friday, February 11. Submit it by attaching your modied les to an e-mail to cburch@cburch.com. From the Web page you can download a set of Java classes that implemen
Hendrix - ASSN - 490
CSci 490, Spring 2005, Assignment 6This assignment, worth 40 points, is due at 3pm, Friday, April 8. Submit it by attaching your modied les to an e-mail to cburch@cburch.com. You can download the base code from the course Web page, which implements
Hendrix - ASSN - 6
CSci 490, Spring 2005, Assignment 6This assignment, worth 40 points, is due at 3pm, Friday, April 8. Submit it by attaching your modied les to an e-mail to cburch@cburch.com. You can download the base code from the course Web page, which implements
Hendrix - CS - 360
CSci 360, Fall 2004, Assignment 9This assignment, worth 40 points, is due Wednesday, November 10, at the beginning of class. You should submit a paper copy of your lambda expressions to my ofce or at the beginning of class. For this assignment, I re
Hendrix - CS - 280
CSci 280, Spring 2009, Exam 1This take-home exam is due Friday, February 13, at 4pm. You should submit your solution on paper, either handwritten or typed. E-mailed solutions will not be accepted. Answer only four of the following ve problems. If yo
Hendrix - CS - 210
Questions 1 Question 8.11: (Solution, p 3) Name at least two generic purposes of an operating system. Question 8.12: (Solution, p 3) One way of receiving a response from a device is to poll it periodically about whether it has any additional informat
Hendrix - CS - 210
CSCI 210 Assn. 5: Caching effectsLab note: You may work with up to one other person on this assignment and submit your solution together, or you may work alone. The write-up is due at 5:00pm on Friday, April 30. It is worth 40 points.ObjectivesA
Hendrix - CS - 210
Questions 1 Question 131: (Solution, p 4) Describe the inputs and outputs of a (1-way) they relate.Question 132: (Solution, p 4) In implementing HYMNs control unit, the fetch cycle and the execute cycle each consisted of two clock phases: one phase
Hendrix - CS - 210
Solutions, Quiz 4, CSCI 210, Spring 20041. When skip is 16,384, each access to arr[i] in the inner loop maps to the same set of cache lines, the lines accessed at the beginning of the inner loop will be dropped from the cache as the inner loop conti
Hendrix - CS - 210
Questions 1 Question 7.31: (Solution, p 2) Describe the contents of the object le that is created by the compiler and subsequently given to the linker. Question 7.32: (Solution, p 2) Describe two advantages of dynamic linking (load-time or run-time)
Hendrix - CS - 210
Questions 1 Question 10.21: (Solution, p 5) Dene the following terms as they relate to processes and threads. a. race b. deadlockQuestion 10.22: (Solution, p 5) At right is a class for representing a long-term computation. It attempts to implement
Hendrix - CS - 210
Quiz 4, CSCI 210, Spring 2004Name: 1. [10 pts] Tests on an Intel Pentium III processor reveal that the performance of the code at right depends heavily on the value of skip. skip 16,352 16,384 time 40 ms 480 msSurprisingly, with a larger value of
Hendrix - CS - 210
Questions 1 Question 6.41: (Solution, p 4) In class, we examined an alternative to using a stack for supporting subroutines, where each subroutine would have its own static memory locations for remembering data. For example, consider the following sq
Hendrix - CS - 210
Lab 8: ThreadsObjectivesto gain experience using threads in a program. to understand competitive and cooperative synchronization.You can run getcs to get a minimal template for this assignment, called PrimeCount.java. Write a Java program that
Hendrix - CS - 210
Lab 6: System callsObjectivesTo become more familiar with the Intel x86 assembly language. To practice the use of interrupts for initiating system calls to Linux. To learn about how parameters typed on a command line are given to a program unde
Hendrix - CS - 210
Quiz 3, CSCI 210, Spring 2004Name: 1. [8 pts] At right, complete the Java program so that it runs two threads. One thread should execute the following code to continually update. totalfor(int i = 1; true; i+) total += i; public class Counter extend
Hendrix - CS - 210
Final, CSCI 210, Spring 2004Name: 1. [5 pts] How many bits does a kilobyte contain? 2. [7 pts] Approximate in the form need not be normalized.) 3. [8 pts] In the following function, you can assume that place is a power of two. Complete the functi
Hendrix - CS - 150
Questions1Question Seq1: (Solution, p 2) Tabulate how the circuit at right changes as the input the inputs at left. 0 1 0 1 0 1 0 1 0 1 DQ QQ1 Q0DQ Qck ! ! ! Question Seq2: (Solution, p 2) Design a ci
Hendrix - CS - 150
Questions1Question J81: (Solution, p 3) Explain the difference between using an instance method in a Java program and using a class method. Question J82: (Solution, p 3) Suppose we were to execute the method . for the at right passing array param
Hendrix - CS - 210
Solutions, Final, CSCI 210, Spring 20041. 2.3. return (number & place) != 0; 4.5 7 7 76.This loop has a common subexpression of 10 * n. We can save time by computing we enter the loop, and reusing this result each iteration.int ten_times_n =
Hendrix - CS - 340
Chapter 1Object-oriented featuresThe compilers job for a procedural language like C is relatively straightforward, because C and most other compiled procedural languages have been designed to approximate what the computer does. Other language para
Muskingum - FREN - 04
Muskingum College Modern Language DepartmentSENIOR SEMINAR RESEARCH PRESENTATIONS IN FRENCH Fall, 2004Dec. 1 6:00 PM 125 BoydSenior Seminar ResearchAll Muskingum language majors complete a senior seminar capstone research project in which they
Muskingum - SEMSPN - 04
Keara Baker Spanish Capstone Seminar Abstract Images of Spanish Women in the Novels El cuarto de atrs and El embrujo de ShanghaiThe topic that I chose to study was the role of women and how each individual woman is viewed in the two contemporary Spa
Muskingum - SEMSPN - 04
Beth Lawson Spanish Capstone Seminar Abstract The Influences that Inspired the Themes of Carmen Martn Gaite and Juan MarsMy Senior Seminar will discuss the works of two authors that grew up in Spain during the civil war, and as a result experienced
Muskingum - SEMSPN - 04
Annabeth Cohen Spanish Capstone Seminar Abstract Ekphrasis and its Application to the Novels El cuarto de atrs by Carmen Martn Gaite and El embrujo de Shanghai by Juan MarsEkphrasis, an element of literature, is the relation between words and images
Muskingum - SEMSPN - 04
Adam Milazzotto Spanish Capstone Seminar Abstract History and Myth in the Novels El embrujo de Shanghai and El cuarto de atrasThis final project for the Spanish Seminar class of Fall 2004 is based upon two contemporary Spanish novels: El embrujo de
Muskingum - SEMSPN - 04
Ryan Hurley-Niezgoda Spanish Capstone Seminar Abstract The Influence of Memory on Intertextuality in the Novels El cuarto de atrs and El embrujo de ShanghaiThe term intertextuality is used to describe how a given text relates to other texts. It is t
Muskingum - SENSEM - 06
Muskingum College Modern Language Department SENIOR SEMINAR RESEARCH PRESENTATION in GERMAN Spring 2006 April 18 6: 00 PM 105 BoydSenior Seminar Research All Muskingum language majors complete a senior seminar capstone research project in which they
Muskingum - MASTERPIEC - 2000
MUSKINGUM COLLEGE Dept. of Modern Languages Dr. Franz-J. Wehage, BSC 227 Office Ph: 826-8301Office hours: MWF 10:30; 12:30; MWF 2:30E-mail:wehage@muskingum.edu German 123 / Masterpieces of German Literature in English Translation. W riting Unit Fa
Muskingum - M - 370
Muskingum - M - 150
Chapter 1Section 1.2 Symbolic LogicSentences vs Statements A truth value is one of two words either true (T) or false (F). A statement is a particular type of sentence whose truth value can always be determined. This means it is always possible by
Muskingum - ACCT - 420
Core Concepts ofACCOUNTING INFORMATION SYSTEMSMoscove, Simkin & BagranoffChapter 2 Documenting Accounting Information Systems Introduction Why Documentation Is Important Document and Systems Flowcharts Data Flow Diagrams Other Documentatio
Hendrix - CS - 150
Questions1Question 3.23: (Solution, p 2) What is the smallest (most negative) number you can represent in twelve bits using sign-magnitude representation? In twos-complement representation? Give both the bit pattern of the number and its decimal
Hendrix - CS - 210
Exam 1, CSCI 210, Spring 2004Name: 1. [10 pts] How would the behavior of the following two Unix shell commands differ?unix% grep open f > wc unix% grep open f | wc2. [5 pts] Suppose we are using an 7-bit oating-point representation with 3 bits fo
Hendrix - CS - 210
Exam 0, CSCI 210, Spring 2004Name: 1. [10 pts] Suppose we have a le called words, which contains the words of the English language, one per line, in random order. Give a Unix command that would display the rst word alphabetically in the English lang
Hendrix - CS - 150
Questions1Question 4.11: (Solution, p 4) Draw two truth tables illustrating the outputs of a half-adder, one table for the output and the other for the output. Question 4.12: (Solution, p 4) Fill in the truth table at right for the following circ
Hendrix - CS - 340
CSci 340, Spring 2003, Assignment 6This assignment is due Friday, May 2, at 4:00pm. You should submit your solution both electronically (using handincs 340 6) and to my ofce (using paper). Your job in this assignment is to write a program that reads
Hendrix - CS - 340
CSci 340, Spring 2003, Assignment 2This assignment is due Friday, February 21 at 5:00pm. You should submit to my ofce a paper copy of the class declaration and methods developed for this assignment. You can transfer text from Squeaks System Browser
Muskingum - ERIC - 07
Basin Research (2007) 19, 5166, doi: 10.1111/j.1365-2117.2007.00318.xOrigin of early overpressure in the Upper Devonian Catskill Delta Complex, western NewYork stateGary G. Lash n and David R. BloodwnDepartment of Geosciences, State University
Muskingum - ERIC - 07
Int J Earth Sci (Geol Rundsch) (2005) 94: 956978 DOI 10.1007/s00531-005-0014-1O R I GI N A L P A P E RH. Broichhausen R. Littke T. HantschelMudstone compaction and its inuence on overpressure generation, elucidated by a 3D case study in the N
Muskingum - ERIC - 07
Plant and Soil 234: 99108, 2001. 2001 Kluwer Academic Publishers. Printed in the Netherlands.99Development of ectomycorrhizas in model beechspruce ecosystems on siliceous and calcareous soil: a 4-year experiment with atmospheric CO2 enrichment a
Muskingum - ERIC - 07
Forest Ecology and Management 223 (2006) 403414 www.elsevier.com/locate/forecoEffects of silvicultural treatments on survival and growth of trees planted on reclaimed mine lands in the AppalachiansChad N. Casselman a,1, Thomas R. Fox a,*, James A.
Muskingum - ERIC - 07
LAND DEGRADATION & DEVELOPMENT Land Degrad. Develop. 9, 115121 (1998)PHOSPHORUS: A LIMITING FACTOR FOR RESTORATION OF SOIL FERTILITY IN A NEWLY RECLAIMED COAL MINED SITE IN XUZHOU, CHINAH. CHEN, C. ZHENG AND Y. ZHUInstitute of Soil Science, Chine
Muskingum - ERIC - 07
Ecological Modelling 114 (1999) 275 286Numerical modelling of biostabilisation for a coal mine overburden dump slopeS.K. Chaulya a, R.S. Singh a, M.K. Chakraborty a, B.B Dhar b,*b a Scientists, En6ironmental Management Group, Central Mining Rese