Print s2disk benchmarks. The image writeout time is saved in the swsusp_info header during suspend, then statistics are printed during resume about elapsed time and image load/store speed for writeout, readin, and total.
--- resume.c | 24 +++++++++++++++++++++++- suspend.c | 11 +++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) Index: suspend-0.2/suspend.c =================================================================== --- suspend-0.2.orig/suspend.c +++ suspend-0.2/suspend.c @@ -16,6 +16,8 @@ #include <sys/mount.h> #include <sys/vt.h> #include <sys/wait.h> +#include <sys/time.h> +#include <time.h> #include <linux/kd.h> #include <linux/tiocl.h> #include <syscall.h> @@ -492,6 +494,7 @@ struct swsusp_info *header = mem_pool; loff_t start; int error; + struct timeval begin; printf("suspend: System snapshot ready. Preparing to write\n"); start = get_swap_page(snapshot_fd); @@ -544,6 +547,7 @@ } } #endif + gettimeofday(&begin, NULL); error = save_image(&handle, header->pages - 1); } if (!error) { @@ -551,6 +555,13 @@ if (compute_checksum) md5_finish_ctx(&handle.ctx, header->checksum); } + fsync(resume_fd); + if (!error) { + struct timeval end; + gettimeofday(&end, NULL); + timersub(&end, &begin, &end); + header->writeout_time = end.tv_usec / 1000000.0 + end.tv_sec; + } if (!error) error = write_area(resume_fd, header, start, page_size); if (!error) { Index: suspend-0.2/resume.c =================================================================== --- suspend-0.2.orig/resume.c +++ suspend-0.2/resume.c @@ -15,6 +15,8 @@ #include <sys/ioctl.h> #include <sys/mman.h> #include <sys/mount.h> +#include <sys/time.h> +#include <time.h> #include <syscall.h> #include <fcntl.h> #include <unistd.h> @@ -512,8 +514,28 @@ if (ret < (int)page_size) error = ret < 0 ? ret : -EIO; } - if (!error) + if (!error) { + struct timeval begin, end; + double delta, mb = header->size / (1024.0 * 1024.0); + + gettimeofday(&begin, NULL); error = load_image(&handle, dev, nr_pages); + gettimeofday(&end, NULL); + + timersub(&end, &begin, &end); + delta = end.tv_usec / 1000000.0 + end.tv_sec; + + printf("wrote %0.1lf MB in %0.1lf seconds (%0.1lf MB/s)\n", + mb, header->writeout_time, mb / header->writeout_time); + + printf("read %0.1lf MB in %0.1lf seconds (%0.1lf MB/s)\n", + mb, delta, mb / delta); + + mb *= 2.0; + delta += header->writeout_time; + printf("total image i/o %0.1lf MB in %0.1lf seconds (%0.1lf MB/s)\n", + mb, delta, mb / delta); + } } if (error) { printf("\nresume: The system snapshot image could not be read.\n\n" ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ Suspend-devel mailing list Suspend-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/suspend-devel