source: tags/arb-6.0/TOOLS/arb_flush_mem.cxx

Last change on this file was 11060, checked in by westram, 10 years ago
File size: 1.6 KB
Line 
1// ================================================================ //
2//                                                                  //
3//   File      : arb_flush_mem.cxx                                  //
4//   Purpose   :                                                    //
5//                                                                  //
6//   Coded by Ralf Westram (coder@reallysoft.de) in December 2012   //
7//   Institute of Microbiology (Technical University Munich)        //
8//   http://www.arb-home.de/                                        //
9//                                                                  //
10// ================================================================ //
11
12#include <arbdb.h>
13#include <arb_misc.h>
14#include <arb_progress.h>
15
16int ARB_main(int , char *[]) {
17    GB_ULONG blocks_to_flush  = GB_get_usable_memory()*4; // no of 256b-blocks
18    GB_ULONG mem_to_flush = blocks_to_flush*256;
19    printf("Flushing %s of your memory\n", GBS_readable_size(mem_to_flush, "b"));
20
21    unsigned char *mem = (unsigned char *)malloc(mem_to_flush);
22    {
23        arb_progress progress("writing mem", blocks_to_flush);
24        for (GB_ULONG p = 0; p<mem_to_flush; ++p) {
25            mem[p] = (unsigned char)p;
26            if (!mem[p]) ++progress;
27        }
28    }
29#if 0
30    ulong sum = 0;
31    {
32        arb_progress progress("reading mem", blocks_to_flush);
33        for (GB_ULONG p = 0; p<mem_to_flush; ++p) {
34            sum += mem[p];
35            if (!mem[p]) ++progress;
36        }
37    }
38    printf("done with sum=%lu\n", sum);
39#endif
40
41    free(mem);
42
43    return EXIT_SUCCESS;
44}
Note: See TracBrowser for help on using the repository browser.