TM for success

本文分享了关于计算机科学课程CS525的成功案例,通过实际教学经验展示如何有效地进行课程设计与实施。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 

 

 

http://www.cs.mum.edu/Courses/cs525/Success.html

void print_statistics(StatRecord *records, int count) { size_t total_send = 0, total_recv = 0; int send_count = 0, recv_count = 0; int success_send = 0, success_recv = 0; printf("\n===== Communication Statistics =====\n"); for (int i = 0; i < count; i++) { char timestr[32]; time_t sec = records[i].time.tv_sec; struct tm *tm_info = localtime(&sec); strftime(timestr, sizeof(timestr), "%H:%M:%S", tm_info); long msec = records[i].time.tv_usec / 1000; if (records[i].is_send) { printf("SEND[%d] | %s.%03ld | Size: %4zu bytes | %s | Retry: %d\n", send_count, timestr, msec, records[i].size, records[i].status ? "SUCCESS" : "FAIL ", records[i].retry_count); total_send += records[i].size; if (records[i].status) { success_send++; } send_count++; } else { printf("RECV[%d] | %s.%03ld | Size: %4zu bytes | %s\n", recv_count, timestr, msec, records[i].size, records[i].status ? "SUCCESS" : "FAIL "); total_recv += records[i].size; if (records[i].status) { success_recv++; } recv_count++; } } printf("\nTotal Send: %zu bytes (%d packets, %d success)\n", total_send, send_count, success_send); printf("Total Recv: %zu bytes (%d packets, %d success)\n", total_recv, recv_count, success_recv); printf("====================================\n"); } void print_statistics(StatRecord *records, int count) { size_t total_send = 0, total_recv = 0; int send_count = 0, recv_count = 0; int success_send = 0, success_recv = 0; printf("\n===== Communication Statistics =====\n"); for (int i = 0; i < count; i++) { char timestr[32]; time_t sec = records[i].time.tv_sec; struct tm *tm_info = localtime(&sec); strftime(timestr, sizeof(timestr), "%H:%M:%S", tm_info); long msec = records[i].time.tv_usec / 1000; if (records[i].is_send) { printf("SEND[%d] | %s.%03ld | Size: %4zu bytes | %s | Retry: %d\n", send_count, timestr, msec, records[i].size, records[i].status ? "SUCCESS" : "FAIL ", records[i].retry_count); total_send += records[i].size; if (records[i].status) { success_send++; } send_count++; } else { printf("RECV[%d] | %s.%03ld | Size: %4zu bytes | %s\n", recv_count, timestr, msec, records[i].size, records[i].status ? "SUCCESS" : "FAIL "); total_recv += records[i].size; if (records[i].status) success_recv++; recv_count++; } } printf("\nTotal Send: %zu bytes (%d packets, %d success)\n", total_send, send_count, success_send); printf("Total Recv: %zu bytes (%d packets, %d success)\n", total_recv, recv_count, success_recv); printf("====================================\n"); } 这两个函数是不是一样的?
最新发布
08-16
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值