Played with it for a bit. What can I say, 
[ImDisk](https://sourceforge.net/projects/imdisk-toolkit) is really slow. May 
be [WinFsp's](https://winfsp.dev/) ram drive is faster, had no time to check 
yet. In regular circumstances I'm pretty content with the former. Adding 
threads brought only negligible improvement, but it would be interesting to 
check the real NVMe drive too.

Here's the code I used to generate the test files (deterministic):
    
    
    import std/[random, tasks, strformat, streams]
    import cozytaskpool
    
    const
      NLines = 3000
      NFiles = 18_000
      LineBytesEst = 32
    
    var
      rnd = initRand(0xDEADBEEF'i64)
      pool = newTaskPool(createConsumer = false)
    
    proc genInputLine(rnd: var Rand): string {.noinit.} =
      let a = rnd.rand(1000_000)
      let b = rnd.rand(10_000_00)
      let c = (rnd.rand(40000) - 20000).float / 100.0
      fmt("{a}\t{b}\tMX890M1E\t{c:.2f}\n")
    
    proc work(fNum: int; seed: int64) =
      var strm = newFileStream(fmt"{fNum:05}.csv", fmWrite)
      var rnd = initRand(seed)
      if not isNil(strm):
        for _ in 1..NLines:
          strm.write(genInputLine(rnd))
        strm.close()
    
    for n in 1..NFiles:
      pool.sendTask(work(n, cast[int64](rnd.next())))
    
    pool.stopPool()
    
    
    Run

Reply via email to