just for anybody who is interested:

I translated Jim's function into window code and added
a page of 1024 that will be written, instead of a single byte.
On my Win-XP system I got 55 TPS, much faster than sqlite
seems to write a page but that might be related to the
additional overhead sqlite needs to do.

This brings me to a nice to have feature request:
How about adding similar test function in the sqlite API ?
This might use the vfs to write pages and gives some feedback
on the performance of the system where sqlite runs on.
It might also detect problems with the commit function...
Just an idea...

Anyway, here is my win32 version Jim's test function:

---
#include    <io.h>
#include        <Fcntl.h>

#define TESTWRITES              1000

int TestDisk ()
{
    int fd;
    int n;
    int loops;
    unsigned char       Page[1024];
    time_t elap;
    time_t start;

    if ((fd=_open("C:\\testfile.db", O_RDWR+O_CREAT, 0777)) == -1)
    {
      fprintf(stderr, "Error opening file");
      exit(1);
    }

    start = time(NULL);
    for(loops=0; loops<TESTWRITES; loops++)
    {
      if (_lseek(fd, 0, SEEK_SET) == -1) {
        fprintf(stderr,"Error seeking file");
        exit(1);
      }

      n = _write(fd, Page, 1024);
      if (n != 1024) {
        fprintf(stderr,"Error writing file");
        exit(1);
      }
      _commit(fd);
    }
    elap = time(NULL)-start;
    fprintf(stderr,"Time: %d seconds; TPS=%f\n", (int)elap, 
TESTWRITES*1.0/((int)elap));

    return(0);
}
-----

Jim Wilcoxson wrote:
> I'm running on Linux with ext3 and just wrote a Python test program to
> insert rows into a table with a single column, no indexing, and doing
> a commit after each insert.  When I first ran it, I got around 440
> inserts per second, which is clearly impossible.  This is a 7200rpm
> drive, so even if I could write a row on every revolution, the maximum
> insert rate would be 120 per second.  I tried adding "pragma
> sychronous=normal", and it sped up to 520 TPS.  With synchronous=full
> it slowed back to 420-460, so this must be the Python default.  Adding
> synchronous=off increased the rate to over 6000 TPS -- basically
> writing to memory instead of disk.
<snip>
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to