im doing performance review of graphdatabases in context of process modelling. therefore set simple testcase tracks performance of simple inserts embedded n4j database. excerpt of testcase.
@test public void insertquants(){ int size =750; /** * create 10 different languages , store them in arraylist */ arraylist<language> lngs = new arraylist<language>(); for(int i=0; i<10; i++){ string title = "testsprache " + string.valueof(i); string description = "beschreibung " +string.valueof(i); lngs.add(modelservice.createlanguage(title,description)); } /** * create different models , assign them different * language objects */ for(int i=0; i<size; i++){ string title = "testmodel " + string.valueof(i); //get random between 0 , 9 int fin = (int) math.round(math.random()*9); //fetch random language object out of arraylist language l = lngs.get(fin); model m = modelservice.createmodel(l, title); l.addmodel(m); template.save(l); }
the methods createmodel in modelservice return specific created object ( model or language ). issue i'm facing random assigning of languages models not working. script assigns each model 1 language object. in mind rather should randomly assign languages model.
the problem not random assignment:
int fin = (int) math.round(math.random()*9);
math.random()
returns double
in range: [0,1)
, multiplying 9 gives: [0,9)
, , rounding gives [0,9]
. cperkins pointed out, using random
may simpler , better (since probability of generating numbers 0 through 9 not uniform method), random number generation range correct. issue not in code have shown us. perhaps it's in addmodel()
or save()
.
Comments
Post a Comment