* (c) 2007 Martin Mares <mj@ucw.cz>
*/
-#include "ucw/lib.h"
-#include "ucw/conf.h"
-#include "ucw/io.h"
-#include "ucw/asio.h"
+#include <ucw/lib.h>
+#include <ucw/conf.h>
+#include <ucw/io.h>
+#include <ucw/asio.h>
+#include <ucw/time.h>
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char **argv)
{
- uns files, bufsize;
+ uint files, bufsize;
u64 total_size;
if (argc != 4 ||
cf_parse_int(argv[1], (int*) &files) ||
return 1;
}
u64 cnt, cnt_rep;
- uns cnt_ms;
+ uint cnt_ms;
int fd[files];
byte name[files][16];
struct asio_request *req[files];
ASSERT(in_fd >= 0);
ASSERT(!(total_size % bufsize));
P_INIT;
- for (uns i=0; i<total_size/bufsize; i++)
+ for (uint i=0; i<total_size/bufsize; i++)
{
struct asio_request *r = asio_get(&io_queue);
r->op = ASIO_WRITE_BACK;
r->fd = in_fd;
r->len = bufsize;
byte *xbuf = r->buffer;
- for (uns j=0; j<bufsize; j++)
+ for (uint j=0; j<bufsize; j++)
xbuf[j] = i+j;
asio_submit(r);
P_UPDATE(bufsize);
#endif
msg(L_INFO, "Initializing output files");
- for (uns i=0; i<files; i++)
+ for (uint i=0; i<files; i++)
{
sprintf(name[i], "tmp/ft-%d", i);
fd[i] = ucw_open(name[i], O_RDWR | O_CREAT | O_TRUNC | DIRECT, 0666);
msg(L_INFO, "Writing %d MB to %d files in parallel with %d byte buffers", (int)(total_size >> 20), files, bufsize);
P_INIT;
- for (uns i=0; i<files; i++)
+ for (uint i=0; i<files; i++)
req[i] = asio_get(&io_queue);
- for (uns round=0; round<total_size/bufsize/files; round++)
+ for (uint round=0; round<total_size/bufsize/files; round++)
{
- for (uns i=0; i<files; i++)
+ for (uint i=0; i<files; i++)
{
struct asio_request *r = req[i];
#ifdef COPY
memcpy(r->buffer, rd->buffer, bufsize);
asio_put(rr);
#else
- for (uns j=0; j<bufsize; j++)
+ for (uint j=0; j<bufsize; j++)
r->buffer[j] = round+i+j;
#endif
r->op = ASIO_WRITE_BACK;
req[i] = asio_get(&io_queue);
}
}
- for (uns i=0; i<files; i++)
+ for (uint i=0; i<files; i++)
asio_put(req[i]);
asio_sync(&io_queue);
#ifdef COPY
msg(L_INFO, "Reading the files sequentially");
P_INIT;
- for (uns i=0; i<files; i++)
+ for (uint i=0; i<files; i++)
{
lseek(fd[i], 0, SEEK_SET);
- for (uns round=0; round<total_size/bufsize/files; round++)
+ for (uint round=0; round<total_size/bufsize/files; round++)
{
struct asio_request *rr, *r = asio_get(&io_queue);
r->op = ASIO_READ;
}
P_FINAL;
- for (uns i=0; i<files; i++)
+ for (uint i=0; i<files; i++)
unlink(name[i]);
#ifdef COPY
unlink("tmp/ft-in");