欧美三区_成人在线免费观看视频_欧美极品少妇xxxxⅹ免费视频_a级毛片免费播放_鲁一鲁中文字幕久久_亚洲一级特黄

SSD06 Exercise04 個人解答

系統 1934 0

?

Profiling Lab: Understanding Program Performance

In this exercise, you will modify an existing program to make it run faster. The program is not written for speed. You will find many things to optimize, but you should concentrate on optimizations that will make a significant impact on run time.

The program is all in one file called substitute.cpp . The purpose of the program is to perform string substitutions on a list of files. The program input is specified on the command line, for example:

      substitute.exe replacements.txt file1.txt file2.txt ... fileN.txt

    

The first file, replacements.txt in this example, contains a list of substitutions to perform. Each string substitution is specified in 3 lines: The first line specifies a string to search for, the next line specifies the replacement string, followed by a blank line. The following is an example substitution file:

      the
that

his
her


    

The remaining files on the command line are the files to be modified. The program reads each file, performs the substitutions one line at a time, and then writes the file. To perform a substitution, the program looks for an exact match to the first string within the file. The matching characters are replaced by the second string. Then the file is searched for another match to the first string. This match is performed on the new state of the file, so it may include characters from any previous substitution. In fact, if the replacement string contains the search string, the program will go into an infinite loop. When no more matches are found, the program moves on to the next line in the substitution file.

A good programming style would be to avoid reading in a whole file at a time because the files might be very large. For this exercise, however, you can assume that there is always enough memory to read the whole file.

Running substitute.exe

Before running substitute.exe, you need some data to run it on. Download this data , create a folder for it, and extract the files from the .zip archive. Since the program will modify some of these files, you will want to either save the .zip archive or save a copy of the files. (You will be running the program many times on this test data.)

To run substitute.exe, you can move it to a directory of your choice, create an MS-DOS command prompt window, and type in the program and command line:

    substitute.exe replace.txt call.cpp compiler.cpp driver.cpp getopt.cpp jnk.cpp mach.cpp  math.cpp semantics.cpp test.cpp
  

Profiling substitute.exe

Once everything is running (check the test files to see that the substitutions were applied), you are ready to start optimizing. The first step will be to use a profiler to find out where the program is spending its time and what it is doing with that time. Consult Appendix A Profiler Customized for SSD6 for more information about the profiler.

Your Assignment

You should make a new version of substitute.exe and demonstrate, using profiling output, that it runs faster. You should be able to obtain at least a factor of 2 speedup (old run time divided by new run time). You do not have to use Microsoft Foundation Class objects, but given that these are well written and probably correct, you should only replace code that is doing unnecessary work as reflected in profiler measurements.

Submit two files:

  1. Your modified substitute.cpp
  2. A file that contains the following
    1. a clear but concise description of what you observed before optimization. It should be substantiated by an empirical evidence of the profiler output.
    2. the bottlenecks you noticed
    3. the actions you took to address the bottlenecks, and the improvements you observed (again substantiated by empirical evidence)
    4. if you had decided to continue with the next most promising code segment for optimization, what would it be? Provide reasons for why you did NOT attempt to pursue that optimization.

To verify the correctness of your solution, compare the output files produced before making any source code changes with the output files produced after making source code changes. Since your optimization should not change the external behavior of the program, the corresponding output files should be identical. If the output files differ, your solution is incorrect. You can use the "comp" command in windows to check if the contents of two files differ.

Note: If any of the files you use for this assessment are stored on a network drive, the network I/O time may dwarf the CPU time consumed by the program and may seriously affect your measurements. Make sure all your files are on the hard drive of your local machine.

Final Word

This project is for educational value only. However, you might be intrigued by the power of a string replacement engine like substitute.exe. Often, in software engineering and even web page maintenance, you will need to perform global replacement of variables, classes, and even misspellings. This is so common in large projects that there are many special tools to facilitate this job. Unix tools such as Find and SED and languages such as Awk and Perl make this kind of job simple. In fact, a SED script to replace strings in a file is not much more complicated than the "replace.txt" file read in by this project. With most tools, you can match patterns, allowing you do more powerful things such as substituting only when the search string is followed by any non-alphanumeric-that is, when the search string is not a prefix of some other identifier.

Few programmers are experts at all of these tools. Novices tend to ignore them and do things the hard way. Experienced programmers know they can learn to use another programming language, they teach themselves what they need to know on an as-needed basis, and they get the job done quickly.

?



?

SSD06 Exercise04 個人解答


更多文章、技術交流、商務合作、聯系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯系: 360901061

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會非常 感謝您的哦!!!

發表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 草久在线观看视频 | 91av在线免费播放 | 天天操夜夜操 | 日韩在线免费视频 | 亚洲成人福利在线观看 | 一区二区在线 | 无码AV免费一区二区三区A片 | 中国一级特黄真人毛片 | chinese 军人 gay xx 呻吟 | 欧美成人26uuu欧美毛片 | 毛片少妇爽到高潮特黄A片 六月色播 | 国产老女人精品毛片久久 | 精品一区二区三区免费毛片 | 日韩精选在线 | 精品一区二区久久久久久久网站 | 黄色国产视频 | 老人与老人免费a级毛片 | 青娱乐欧美视频 | 白色白色视频免费观看 | 色综合天天综一个色天天综合网 | 欧美日韩国产一区二区三区不卡 | 一区二区三区毛A片特级 | 性夜影院爽黄A爽免费动漫 日韩精品在线一区二区 | 欧美影院推理片免费看 | 国产精品久久久久久久四虎电影 | 成人欧美日韩一区二区三区 | 国产日韩欧美在线观看不卡 | 999热视频| 欧美精品 在线观看 | 日本福利在线观看 | 亚洲精品久久久久久中文字幕小说 | 日本香蕉一区二区三区 | 亚洲免费在线观看 | h久久| 一级毛片 在线播放 | 黄色av电影在线播放 | 久久久久综合精品福利啪啪 | 日韩一区中文字幕 | 天天做天天爱夜夜爽女人爽宅 | 狠狠色欧美亚洲狠狠色www | 99亚洲精品高清一二区 |