Bugs:
        o If you forget to call Open(), it segfaults

        o No data writeout until compact?

        o Inserting 100,000 blocks is horribly slow (I know, you're
          fixing it) -- it's still running, now at 17 minutes, and
          only 52,000 blocks...39:00 - 79,000 blocks...
          44:00 - 84,000... all in all, it took 1:19:20 (yes, over
          an hour!) and ate over 5 megs of RAM. And it created a blank,
          46-byte file! Who ate my data?!

        o To long string at prompt = segfault (buffer overflow!)

        o Adding blocks is in quadratic [ O(n^2) ] time! This is a crime
          against humanity! (tester to prove this attached)

        o Destructor did not write data to file -- was it supposed to?
          Or must I call close()?

        o Constructor did not open file -- it should, to be simular to
          an fstream.

        o No man file

        o No configure file to set up XEndianFile
--
#include <iostream.h>
#include <stdlib.h>
#include "XBlockFile.h"
#include <time.h>

#define NUM_BLOCKS 20000

int main() {
        XBlockFile xbf("test2.file");
        xbf.Open(true);
        cerr << "Inserting blocks...";
        clock_t ta[NUM_BLOCKS/1000];
        clock_t first_clock = clock();
        for (int x = 1; x <= NUM_BLOCKS; ++x) {
                if (!(x % 1000)) {
                        ta[x/1000-1] = clock();
                        cerr << x << "...";
                }
                xbf.SetBlock(0x00000000ul,x,&x,sizeof(x));
        }
        clock_t max_t = 0;
        for (int x = 0; x < NUM_BLOCKS/1000; ++x) {
                ta[x] -= first_clock;
                if (max_t < ta[x])
                        max_t = ta[x];
        }
        double scale = 80.0/max_t;
        cout << endl << endl;
        for (int x = 0; x < NUM_BLOCKS/1000; ++x) {
                for (int y = 0; y < (unsigned long)(scale*ta[x]); ++y)
                        cout << '#';
                cout << endl;
        }
}

Reply via email to