<commit_before>#!/usr/bin/env coffee

fs = require 'fs'
path = require 'path'
SpanSkipList = require '../src/span-skip-list'
_ = require 'underscore'

lines = fs.readFileSync(path.join(__dirname, 'large.js'), 'utf8').split('\n')
offsetIndex = new SpanSkipList('rows', 'characters')

times = 25
count = 0
time = 0

while count < times
  offsets = lines.map (line, index) -> {rows: 1, characters: line.length + 1}
  start = Date.now()
  offsetIndex.spliceArray('rows', 0, lines.length, offsets)
  time += Date.now() - start
  lines = _.shuffle(lines)
  count++

console.log "Inserting #{lines.length * times} lines took #{time}ms (#{Math.round(lines.length * times / time)} lines/ms)"<commit_msg>Make benchmark easier to profile in Atom<commit_after>#!/usr/bin/env coffee

fs = require 'fs'
path = require 'path'
SpanSkipList = require '../src/span-skip-list'
_ = require 'underscore'

lines = fs.readFileSync(path.join(__dirname, 'large.js'), 'utf8').split('\n')
offsetIndex = new SpanSkipList('rows', 'characters')

times = 25
count = 0
time = 0

offsetsToInsert = []
while count < times
  offsetsToInsert.push lines.map (line, index) -> {rows: 1, characters: line.length + 1}
  lines = _.shuffle(lines)
  count++

start = Date.now()
for offsets in offsetsToInsert
  offsetIndex.spliceArray('rows', 0, offsets.length, offsets)
time = Date.now() - start

console.log "Inserting #{lines.length * times} lines took #{time}ms (#{Math.round(lines.length * times / time)} lines/ms)"
{'fraction_non_alphanumeric': 0.16395663956639567, 'fraction_numerical': 0.01084010840108401, 'mean_word_length': 4.531835205992509, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1651625', 'n_tokens_mistral': 516, 'n_tokens_neox': 495, 'n_words': 134}