Commit 822b420d authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 9d7e53ca
...@@ -74,7 +74,7 @@ XXX ...@@ -74,7 +74,7 @@ XXX
from __future__ import print_function, absolute_import from __future__ import print_function, absolute_import
import sys import os, sys
from golang import func, defer, panic from golang import func, defer, panic
from golang import time from golang import time
from ZODB import DB from ZODB import DB
...@@ -118,7 +118,7 @@ class ZCtx(object): ...@@ -118,7 +118,7 @@ class ZCtx(object):
valdict = zctx.root.get('treegen/values', None) valdict = zctx.root.get('treegen/values', None)
if valdict is None: if valdict is None:
valdict = zctx.root['treegen/values'] = PersistentMapping() valdict = zctx.root['treegen/values'] = PersistentMapping()
valv = b'abcdefghi' valv = b'abcdefgh'
for v in valv: for v in valv:
zblk = valdict.get(v, None) zblk = valdict.get(v, None)
if zblk is not None and zblk.loadblkdata() == v: if zblk is not None and zblk.loadblkdata() == v:
...@@ -305,7 +305,8 @@ def AllStructs(kv1txt, kv2txt, maxdepth, maxsplit, n, seed=None): ...@@ -305,7 +305,8 @@ def AllStructs(kv1txt, kv2txt, maxdepth, maxsplit, n, seed=None):
# seed # seed
if seed is None: if seed is None:
seed = int(time.now()) seed = time.now()
seed = int(seed)
random.seed(seed) random.seed(seed)
print("# maxdepth=%d maxsplit=%d n=%d seed=%d" % (maxdepth, maxsplit, n, seed)) print("# maxdepth=%d maxsplit=%d n=%d seed=%d" % (maxdepth, maxsplit, n, seed))
...@@ -451,9 +452,10 @@ def cmd_allstructs(argv): ...@@ -451,9 +452,10 @@ def cmd_allstructs(argv):
maxdepth = int(argv[0]) maxdepth = int(argv[0])
maxsplit = int(argv[1]) maxsplit = int(argv[1])
n = int(argv[2]) n = int(argv[2]) # XXX -> nsample?
kv1, kv2 = argv[3:] kv1, kv2 = argv[3:]
AllStructs(kv1, kv2, maxdepth, maxsplit, n) seed = os.environ.get("treegen_SEED")
AllStructs(kv1, kv2, maxdepth, maxsplit, n, seed)
@func @func
def cmd_trees(argv): def cmd_trees(argv):
......
...@@ -27,13 +27,16 @@ import ( ...@@ -27,13 +27,16 @@ import (
"fmt" "fmt"
"io" "io"
"io/ioutil" "io/ioutil"
"math/rand"
"os" "os"
"os/exec" "os/exec"
"reflect" "reflect"
"regexp" "regexp"
"sort" "sort"
"strconv"
"strings" "strings"
"testing" "testing"
"time"
"lab.nexedi.com/kirr/go123/exc" "lab.nexedi.com/kirr/go123/exc"
"lab.nexedi.com/kirr/go123/xerr" "lab.nexedi.com/kirr/go123/xerr"
...@@ -453,11 +456,33 @@ func TestΔBTreeAllStructs(t *testing.T) { ...@@ -453,11 +456,33 @@ func TestΔBTreeAllStructs(t *testing.T) {
// XXX explain that py program startup is very slow due to // XXX explain that py program startup is very slow due to
// pkg_resources (+ link) -> we use server + request/response. // pkg_resources (+ link) -> we use server + request/response.
seed := time.Now().UnixNano()
seeds := os.Getenv("DBTail_SEED")
if seeds != "" {
var err error
seed, err = strconv.ParseInt(seeds, 10, 64)
if err != nil {
t.Fatalf("invalid $DBTail_SEED=%s: %s", seeds, err)
}
}
t.Logf("# seed=%d", seed)
rng := rand.New(rand.NewSource(seed))
maxdepth := 2 // XXX -> 3? maxdepth := 2 // XXX -> 3?
maxsplit := 1 // XXX -> 2? maxsplit := 1 // XXX -> 2?
n := 10 // XXX -> more?
/*
kv1 = {}
for keys := range IntSets(5) { // XXX !short -> ↑
kv2 = {k -> v=random.choice('abcdefgh'); for k in keys }
}
*/
_ = maxdepth; _ = maxsplit _ = maxdepth; _ = maxsplit; _ = n; _ = rng
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment