当前位置:网站首页>Gossip about the 88 of redis source code
Gossip about the 88 of redis source code
2022-06-12 18:00:00 【Tao song remains the same】
This is actually a test program , Related to file operation , It's very simple :
#include <stdio.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <stdlib.h>
#include <unistd.h>
#include <time.h>
int main(int argc, char **argv) {
struct stat stat;
int fd, cycles;
if (argc != 3) {
fprintf(stderr,"Usage: <filename> <cycles>\n");
exit(1);
}
srand(time(NULL));
char *filename = argv[1];
cycles = atoi(argv[2]);
fd = open(filename,O_RDWR);
if (fd == -1) {
perror("open");
exit(1);
}
fstat(fd,&stat);
while(cycles--) {
unsigned char buf[32];
unsigned long offset = rand()%stat.st_size;
int writelen = 1+rand()%31;
int j;
for (j = 0; j < writelen; j++) buf[j] = (char)rand();
lseek(fd,offset,SEEK_SET);
printf("Writing %d bytes at offset %lu\n", writelen, offset);
write(fd,buf,writelen);
}
return 0;
}
边栏推荐
- Explanation of core interrupt of Godson processor
- leetcode 300. Longest increasing subsequence
- Database SQL operation Basics
- Soringboot下RestTemplateConfig 配置打印请求响应日志
- 字节飞书人力资源套件三面
- 续2 asp.net core 路由程序基础使用演示0.2 默认控制器数据的获取到
- Lightweight and convenient small program to app technology solution to realize interconnection with wechat / traffic app
- Graphical data model for system design
- Section qemu+gdb
- General differences between SQL server versions released by Microsoft in different periods so far, for reference
猜你喜欢

SSM集成FreeMarker以及常用语法

机器学习系列(5):朴素贝叶斯

App中快速复用微信登录授权的一种方法

DRM driven MMAP detailed explanation: (I) preliminary knowledge

Article name
Goframe gredis configuration management | comparison of configuration files and configuration methods

1.5 what is an architect (serialization)

General differences between SQL server versions released by Microsoft in different periods so far, for reference

A method of quickly reusing wechat login authorization in app

Schedule update | 2022 Microsoft and Intel hacker song competition is in hot registration
随机推荐
566. reshaping the matrix
leetcode 718 最长公共子串
HTTP缓存<强缓存与协商缓存>
小程序和App同时拥有?两者兼得的一种技术方案
Goframe gredis configuration management | comparison of configuration files and configuration methods
vant3+ts 封装uploader上传图片组件
Common dependencies of SSM
C business serial number rule generation component
Window版本pytorch入门深度学习环境安装与配置
vant3+ts DropdownMenu 下拉菜单,数据多能滚动加载
Schematic diagram of active differential crystal oscillator and differences among lv-pecl, LVDS and HCSL
Schedule update | 2022 Microsoft and Intel hacker song competition is in hot registration
有关cookie的用法介绍
在同花顺开户证券安全吗
ftrace
EasyCode模板
利用小程序快速生成App,只需七步
SQL游标(cursor)详细说明及内部循环使用示例
字节飞书人力资源套件三面
用好IDE,研发效能提速100%