当前位置: 首页 > news >正文

网站有死链接怎么办做网站必须原创吗

网站有死链接怎么办,做网站必须原创吗,wordpress 更改头像,上海做网站的多吗1.开发背景 Linux 系统提供了各种外设的控制方式#xff0c;其中包括文件的读写#xff0c;存储文件的介质可以是 SSD 固态硬盘或者是 EMMC 等。 其中常用的写文件方式是同步写操作#xff0c;但是如果是写大文件会对 CPU 造成比较大的负荷#xff0c;采用异步写的方式比较…1.开发背景 Linux 系统提供了各种外设的控制方式其中包括文件的读写存储文件的介质可以是 SSD 固态硬盘或者是 EMMC 等。 其中常用的写文件方式是同步写操作但是如果是写大文件会对 CPU 造成比较大的负荷采用异步写的方式比较合适并且需要直接越过内核直接通过 IO 访问直接访问磁盘关键词 O_DIRECT。可以有效降低 CPU 的使用率。 #ifdef __USE_GNU # define O_DIRECT __O_DIRECT /* Direct disk access. */ # define O_NOATIME __O_NOATIME /* Do not set atime. */ # define O_PATH __O_PATH /* Resolve pathname but do not open file. */ # define O_TMPFILE __O_TMPFILE /* Atomically create nameless file. */ #endif添加宏定义否者 O_DIRECT 显示未定义 #define _GNU_SOURCE2.开发需求 设计实验 1使用同步写硬盘的方式连续 100MB 的数据 10 次并统计每次写入的时间和速度 2使用异步写硬盘的方式连续 100MB 的数据 10 次并统计每次写入的时间和速度 3.开发环境 ubuntu20.04  RK3568  Linux4.19.232 金士顿 SSD 4.实现步骤 4.1 实现代码 #define _GNU_SOURCE#include stdio.h #include stdlib.h #include fcntl.h #include unistd.h #include string.h #include errno.h #include linux/fs.h #include sys/time.h#include com_file.h #include app_log.h#define BUFFER_SIZE (1024 * 1024 * 100) // 100MB #define TEST_FILE_PATH /run/media/sata/output.dat/* 同步写测试 */ static void test_write_sync(char *file_path, char *buffer) {/* 创建文件和路径 */common_file_create(file_path);/* 打开文件 */int fd open(file_path, O_WRONLY | O_CREAT, 0644);if (fd 0) {alog_error(open failed\r\n);return;}/* 写数据 */if (write(fd, buffer, BUFFER_SIZE) ! BUFFER_SIZE) {alog_error(write failed\r\n);close(fd);return;}/* 关闭文件 */close(fd); }/* 异步写测试 */ static void test_write_async(char *file_path, char *buffer) {/* 创建文件和路径 */common_file_create(file_path);/* 打开文件 */int fd open(file_path, O_WRONLY | O_CREAT | O_DIRECT, 0644);if (fd 0) {alog_error(open failed\r\n);return;}/* 写数据 */if (write(fd, buffer, BUFFER_SIZE) ! BUFFER_SIZE) {alog_error(write failed\r\n);close(fd);return;}/* 关闭文件 */close(fd); }/* 主程序 */ int main() {alog_info(%s start\r\n, __func__);char file_path[] TEST_FILE_PATH;char *pdata_sync NULL;char *pdata_async NULL;/* 初始化同步内存 */pdata_sync (char *)malloc(BUFFER_SIZE);if (pdata_sync NULL){alog_error(malloc failed\r\n);return 1;}alog_info(sync memory init ok\r\n);/* 初始化异步内存 */if (posix_memalign((void **)pdata_async, 512, BUFFER_SIZE) ! 0) // 512 4096{alog_error(posix_memalign failed\r\n);return 1;}alog_info(async memory init ok\r\n);/* 填充数据 */for (long long int i 0; i BUFFER_SIZE; i){pdata_sync[i] i 0xFF;pdata_async[i] i 0xFF;}alog_info(data init ok\r\n);/* 计时*/struct timeval start_time;struct timeval end_time;/* 同步写测试 */for (int i 0; i 10; i){gettimeofday(start_time, NULL);test_write_sync(file_path, pdata_sync);gettimeofday(end_time, NULL);int usec_sync (end_time.tv_sec - start_time.tv_sec) * 1000000 (end_time.tv_usec - start_time.tv_usec);double speed_sync (double)BUFFER_SIZE / ((double)usec_sync / 1000 / 1000);alog_info(sync[%d] write test time: %d ms, speed: %lf MB/s\r\n, i, usec_sync / 1000, speed_sync / (1024 * 1024));}/* 异步写测试 */for (int i 0; i 10; i){gettimeofday(start_time, NULL);test_write_async(file_path, pdata_async);gettimeofday(end_time, NULL);int usec_async (end_time.tv_sec - start_time.tv_sec) * 1000000 (end_time.tv_usec - start_time.tv_usec);double speed_async (double)BUFFER_SIZE / ((double)usec_async / 1000 / 1000);alog_info(async[%d] write test time: %d ms, speed: %lf MB/s\r\n, i, usec_async / 1000, speed_async / (1024 * 1024));}/* 释放内存 */free(pdata_sync);free(pdata_async);return 0; }4.2 测试结果 异步写硬盘速度更快并且 CPU 占用更低只有不到 20%同步写硬盘 CPU 占用超过 90%
http://www.w-s-a.com/news/548642/

相关文章:

  • 平谷建站推广广告投放平台主要有哪些
  • 网站备案掉了什么原因步骤怎么读
  • 徐州市建设监理协会网站做一个公司官网需要多少钱
  • 网站开发学什么数据库做公司网站注意事项
  • 游戏开发网站建设国际战事最新消息
  • 达州+网站建设网站里自己怎么做推广
  • 看网站建设公司的网站案例熊掌号接入wordpress
  • 黄石下陆区建设局网站wordpress如何拖移小工具
  • 宁波网站建设信息网站开发看书
  • 网站建设优化价格北京优化seo排名
  • 微信网站建设公司费用高端网站建设 炫酷
  • 北京网站假设销售找客户最好的app
  • 做外贸需要关注的网站有什么好处宜州设计公司
  • 公司最近想做个网站怎么办陕西科强建设工程有限公司官方网站
  • 生态城门户网站 建设动态it外包收费
  • 网站项目评价老渔哥网站建设公司
  • 哈尔滨寸金网站建设价格178软文网
  • 一个网站建设的成本网站开发过程及要点
  • 监控视频做直播网站中国建筑人才网下载
  • 网站建设公司华网天下买送活动集团网站设计案例
  • 哪些网站比较容易做哪个网站做中高端衣服
  • 做php网站教程wordpress去水印
  • 深圳微网站建设公司哪家好潍坊专业做网站的公司
  • 网站的弹窗广告怎么做软件开发包括
  • 网站开发人员保密做最优秀的自己演讲视频网站
  • 一般做网站要多少钱怎样选择高性价比的建站公司
  • 免费私人网站建设软件高端网站设计平台高端网站设计企业
  • 响应式网站建设的应用场景怎么申请电商平台
  • 怎么做垂直自营网站游戏咨询网站建设目标是什么
  • 建设网站需要给钱吗建立网站三大基础