Ejemplo n.º 1
0
/**
 * Generate a join bench test.
 *
 * @param  {String} name
 * @param  {Number} size
 * @param  {Function} hashJoin
 * @param  {Function} sortedMergeJoin
 * @param  {Function} nestedLoopJoin
 * @return {Benchmark.Suite}
 */
export default function joinBench (name, size, hashJoin, sortedMergeJoin, nestedLoopJoin) {
    const chance = new Chance();
    chance.mixin({row: () => ({id: chance.character({pool: 'aeiouy'})})});
    const left = chance.n(chance.row, size),
        right = chance.n(chance.row, size),
        accessor = obj => obj.id;
    return {
        name,
        tests: {
            'Hash Join': () => hashJoin(left, accessor, right, accessor),
            'Sorted Merge Join': () => sortedMergeJoin(left, accessor, right, accessor),
            'Nested Loop Join': () => nestedLoopJoin(left, accessor, right, accessor)
        }
    };
}
  beforeEach('set up', () => {
    chance = new Chance();

    listOfThings = chance.n(makeThing, chance.integer({
      min: 15,
      max: 30,
    }));
  });
Ejemplo n.º 3
0
 lists: _.times(3, function generateLists (index) {
   return {
     id: index + 1,
     title: 'My List ' + chance.word() + '  ' + (index + 1),
     hidden: false,
     items: _.uniq(chance.n(chance.d30, 10))
   };
 }),
  beforeEach('set up', () => {
    chance = new Chance();
    listOfGroups = [
      {
        group: 'group-one',
        collections: chance.n(() => ({ collection: chance.sentence() }), chance.integer({ min: 3, max: 7 })),
      },
      {
        group: 'group-two',
        collections: chance.n(() => ({ collection: chance.sentence() }), chance.integer({ min: 3, max: 7 })),
      },
      {
        group: 'group-three',
        collections: chance.n(() => ({ collection: chance.sentence() }), chance.integer({ min: 3, max: 7 })),
      },
    ];

    [expectedGroup, expectedCollection] = pickRandomGroupAndCollection(listOfGroups, chance);
  });
Ejemplo n.º 5
0
    it('assigns name, sortable, filterable, and esTypes options to itself', () => {
      const name = chance.word();
      const sortable = chance.bool();
      const filterable = chance.bool();
      const esTypes = chance.n(chance.word, 3);

      expect(new KbnFieldType({ name, sortable, filterable, esTypes }))
        .to.have.property('name', name)
        .and.have.property('sortable', sortable)
        .and.have.property('filterable', filterable)
        .and.have.property('esTypes').eql(esTypes);
    });
Ejemplo n.º 6
0
  constructor() {
    const chance = new Chance();

    this.id = uuid.v4();

    this.title = chance.n(chance.word, chance.natural({min: 2, max: 4}))
      .map(a => a.charAt(0).toUpperCase() + a.substr(1))
      .join(' ');

    this.author = {
      name: chance.name(),
      gender: chance.gender(),
    }

    this.genre = chance.pickone(["Science fiction","Satire","Drama","Action and Adventure","Romance","Mystery","Horror",
      "Self help","Health","Guide","Travel","Children's","Religion, Spirituality & New Age","Science","History","Math",
      "Anthology","Poetry","Encyclopedias","Dictionaries","Comics","Art","Cookbooks","Diaries","Journals","Prayer books",
      "Series","Trilogy","Biographies","Autobiographies","Fantasy","Finance"])

    this.publishedAt = chance.date({string: true, year: chance.natural({min: 1970, max: 2015}), american: false});
  }
Ejemplo n.º 7
0
import Chance from 'chance';
import scaleLinear from 'd3-scale/src/linear';
import Chart from '../lib/chart/Bar';

// Test Data
const chance = new Chance();
chance.mixin({row: () => ({
    date: chance.date({year: 2016}),
    vowels: chance.character({pool: 'aeiouy'}),
    county: chance.country(),
    age: chance.age({type: 'adult'}),
    bool: chance.bool(),
    float: chance.floating({min: -25, max: 25}),
    integer: chance.integer({min: -25, max: 25}),
    positiveInteger: chance.integer({min: 0, max: 25}),
    string: chance.string({length: 4})
})});
const data = chance.n(chance.row, 100);

(new Chart())
    .key(d => d.age, scaleLinear())
    .value(d => d.positiveInteger)
    .attach('#chart')
    .draw(data);