讲解:ENGR9881、Monitoring、C++、C++Haskell|C/C++

ENGR9881 Computer Networks GECN Workshop05: MonitoringDue: Friday, 14 May 2019Lab 5 is comprised of 4 tasks; Task 4 is worth 2 checkpoints, each other task is worth 1 checkpoint with,each checkpoint contributing 1% towards your topic grade. Following completion of the checkpoints, acopy of the source code and output for each task should be compiled into a single text file and uploaded tothe relevant submission box on FLO for moderation. Speak to your demonstrator if you are unsure how todo this.While discussion of programming tasks with fellow students in labs is welcome and encouraged, please bemindful of the Universitys Academic Integrity policy and refrain from simply copying another studentscode (even if they agree!). You will gain a much greater understanding of the material if you take the time towork through your own solutions, and you will be expected to be able to explain your code before beingawarded checkpoints. Remember, the demonstrators are there to help if you get stuck.ObjectivesUpon completing they lab, you should be able to: Profile C programs to explore run time information to observe the time that programs take to run Use optional debug statements to enable/disable debugging code Use system functions (stat) to access file metadata to observe the time and date fields that are used byfiles in the file systemLearning out comes; LO2: Demonstrate the design and implementation of simple process and network level programsVersion 1.3 Page 1 of 5 2019/Jan/10Talk 1Write a program that calculates and prints the elapsed time of a loop to an accuracy of microseconds.1. Use the structure timeval to store times form the following C header file;#include 3. In a loop that executes 100 times Use gettimeofday() to get the time Iterate through a loop 1,000,000 times Use gettimeofday() to get the clasped time4. Calculate and print the time taken in microseconds for each loop and entire programexecutionSee;man 2 gettimeofdayVersion 1.3 Page 2 of 5 2019/Jan/10Task 2Write a program that uses the function getopt() to parse command line options, print providedoptions.1. Call a function usage() if there are no command line arguments2. With in a suitable loop (refer to the getopt man page for example code1. Use getopt() to parse the command line options2. With in a switch/caENGR9881作业代写、Monitoring留学生作业代做、代写C++实验作业、代做C++程序语言作业 帮做Haskese statement1. Process arguments and print each option and argument2. In the switch control structure set the default case and ‘?’ to call usage() ifincorrect arguments are providedvoid usage () {printf(“Usage: programname -f filename”);}See;man 3 getoptVersion 1.3 Page 3 of 5 2019/Jan/10Task 3Write a program that uses stat() to collect the metadata about a file and print out each of thefields, display all the relevant time and/or date related fields.1. Use getopt() to provide a the command line argument of the file name2. Use the following C header file;#include 3. Use stat() and the structure in the stat man page to find the metadata about the provided file4. Print each of the time related elements of the structure with the appropriate format anddescription;struct stat {dev_t st_dev; /* device inode resides on */ino_t st_ino; /* inodes number */mode_t st_mode; /* inode protection mode */…}5. Using the above comments in the structure in the man page;printf(“device inode resides on: ‘%d’\n”, file->st_dev);printf(“inode’s number: ‘%d’\n”, file->st_ino);printf(“inode’s number: ‘%d’\n”, file->st_ino);…6. How can the time stamp on files be used to determine performance and timing?See;man 2 statVersion 1.3 Page 4 of 5 2019/Jan/10Task 4Copy the source code for task 1 and add DEBUG statements around the timing functionality toallow optional use of timing. Part 11. add a #define statement at the top of your code for DEBUG 1 for true and DEBUG 0 forfalse2. Use an if statement to allow for conditional execution of the timing functionsif (DEBUG) {gettimeofday();}3. Collect run time information in the shell with the command time, for each of DEBUG 1and DEBUG 0? Part 24. add a #define statement at the top of your code for DEBUG5. Use an #ifdef and #endif statement to allow for conditional compilation and execution ofthe timing functions#ifdef DEBUGgettimeofday()#endif6. Collect run time information in the shell with the command time, for each of DEBUG 1and DEBUG 0 Part 37. Is it possible to measure any difference between using the techniques in part 1 and part 2?8. Is it possible to measure the difference in execution time with the command line time?See;man 2 statVersion 1.3 Page 5 of 5 2019/Jan/10转自:http://www.7daixie.com/2019051347625186.html

你可能感兴趣的:(讲解:ENGR9881、Monitoring、C++、C++Haskell|C/C++)