当前位置:网站首页>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;
}
边栏推荐
- Two ways of tensorflow2 training data sets
- Resttemplateconfig configuration print request response log under soringboot
- About datasets
- js快速排序
- es7不使用父子和嵌套关系来实现一对多功能
- 使用MongoDB官方go库操作MongoDB原创
- 73. matrix zeroing (marking method)
- First principles of enterprise architecture
- Cesium parabolic equation
- Sqlserver common statements and functions
猜你喜欢

C#简单介绍

Vant3+ts dropdownmenu drop-down menu, multi data can be scrolled

An easy-to-use IDE for small programs

TypeScript类型声明文件(三)

ES7 does not use parent-child and nested relationships to implement one to many functions

Explanation of core interrupt of Godson processor

Global lock, table lock, row lock

Use applet to quickly generate app in seven steps

小程序+App,低成本获客及活跃的一种技术组合思路

C operation database added business data value content case school table
随机推荐
Click the list page of vant3+ts+pinia tab to enter the details. The tab on the details page is highlighted in the original position, and the refresh highlight is in the first item by default
[CSP]202012-2期末预测之最佳阈值
NixOS 22.05安装过程记录
grpc-swift入门
Applet and app are owned at the same time? A technical scheme with both
数组按指定顺序排序
Leetcode491 increasing subsequence
消息队列存储消息数据的 MySQL 表格
低代码平台调研结果
Are Huishang futures accounts reliable? Is the fund safe?
First principles of enterprise architecture
Is Huishang futures company reliable in opening accounts and safe in trading?
Arm64 stack backtracking
联想回应笔记本太多太杂乱:现在是产品调整期 未来将分为数字/Air/ Pro三大系列
Reconstruction -- sort out and decompose the inheritance system
DRM driven MMAP detailed explanation: (I) preliminary knowledge
Make good use of IDE, speed up R & D efficiency by 100%
js快速排序
Common dependencies of SSM
Original error interface