File: asyncio.c

package info (click to toggle)
pmix 6.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 12,364 kB
  • sloc: ansic: 134,173; sh: 4,271; python: 2,785; makefile: 2,286; xml: 1,611; perl: 1,341; lex: 138
file content (38 lines) | stat: -rw-r--r-- 965 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>

#define REPS 2

char data[1024];

int main(int argc, char *argv[])
{
    int n, size, start, end, delay;

    /* write a line out that has a newline at the end */
    memset(data, 0, sizeof(data));
    memcpy(data, "BEGIN123456788865432356897654345678END\n", strlen("BEGIN123456788865432356897654345678END\n"));
    write(1, data, strlen(data));

    for (n=0; n < REPS; n++) {
        fprintf(stdout, "REP %d\n", n);
        start = 0;
        delay = random() % 4;
 //       sleep(delay);
        memset(data, 0, sizeof(data));
        memset(data, 'A', 1024);
        end = 100;
        write(1, data, end);
        start += end;
        delay = random() % 4;
   //     sleep(delay);
        write(1, &data[start], end);
        start += end;
        delay = random() % 4;
  //      sleep(delay);
        write(1, &data[start], 1024 - start);
        fprintf(stdout, "\n");
    }
}