<commit_before>'use strict'
// -------------------------
var Stats = require('stats-js')
var stats = new Stats()
stats.setMode(0)
document.body.appendChild(stats.domElement)
// -------------------------
var subscribe = require('../../subscribe')
var s = require('../../s')
var state = s({ something: {} })
var amount = 8e3
// -------------------------
var cnt = 0
var canvas = document.createElement('canvas')
canvas.id = 'canvas'
canvas.width = 1000
canvas.height = 1000
document.body.style.backgroundColor = 'rgb(38,50,56)'
document.body.appendChild(canvas)
var context = canvas.getContext('2d')
var dir = 2
context.fillStyle = 'rgb(128,263,192)'
// -------------------------
function goCanvas () {
  stats.begin()
  context.clearRect(0, 0, canvas.width, canvas.height)
  cnt += dir
  if (cnt > 2500 || cnt < 1) {
    dir = -1 * dir
  }
  var x = {}
  for (var i = 0; i < amount; i++) {
    x[i] = i + cnt
  }
  state.something.set(x)
  stats.end()
  window.requestAnimationFrame(goCanvas)
}
// -------------------------
function listen (target, type, stamp) {
  var val = target.compute()
  var i = target.key
  var x =
    Math.sin(val / 5 + cnt / 40) * 300 +
    i * 0.02 + 500 +
    Math.cos(val + cnt / (40 - i / 1000)) * 10
  var y =
    Math.cos(val / 10) * 300 +
    i * 0.02 + 500 +
    Math.sin(val + cnt / (40 - i / 1000)) * 10
  context.fillRect(x, y, 1, 1)
}
// -------------------------
var tree = subscribe(state, { something: { $any: { val: true } } }, listen)<commit_msg>perf test for root, seems fast<commit_after>'use strict'
// -------------------------
var Stats = require('stats-js')
var stats = new Stats()
stats.setMode(0)
document.body.appendChild(stats.domElement)
// -------------------------
var subscribe = require('../../subscribe')
var s = require('../../s')
var state = s({
  something: {},
  // dot: 100
})
var amount = 8e3
// -------------------------
var cnt = 0
var canvas = document.createElement('canvas')
canvas.id = 'canvas'
canvas.width = 1000
canvas.height = 1000
document.body.style.backgroundColor = 'rgb(38,50,56)'
document.body.appendChild(canvas)
var context = canvas.getContext('2d')
var dir = 2
context.fillStyle = 'rgb(128,263,192)'

var x = {}
for (var i = 0; i < amount; i++) {
  x[i] = i
}
state.something.set(x)


global.fires = 0
// -------------------------
function goCanvas () {
  stats.begin()
  context.clearRect(0, 0, canvas.width, canvas.height)
  cnt += dir
  if (cnt > 2500 || cnt < 1) {
    dir = -1 * dir
  }
  var x = {}
  for (var i = 0; i < amount; i++) {
    x[i] = { title: i + cnt }
  }
  state.something.set(x)

  // console.log(fires)
  // state.dot.set(Math.random())
  stats.end()
  window.requestAnimationFrame(goCanvas)
}
// -------------------------

function listen (target, type, stamp) {
  global.fires++
  // console.log(target)
  var val = target.compute()
  var i = target.parent.key

  var x =
    Math.sin(val / 5 + cnt / 40) * 300 +
    i * 0.02 + 500 +
    Math.cos(val + cnt / (40 - i / 1000)) * 10
  var y =
    Math.cos(val / 10) * 300 +
    i * 0.02 + 500 +
    Math.sin(val + cnt / (40 - i / 1000)) * 10
  context.fillRect(x, y, 1, 1)
}
// -------------------------
// lets opt the shit out of it

var tree = subscribe(state, {
  something: {
    val: 1,
    $remove: true,
    $any: {
      val: 1,
      $remove: true,
      title: { val: true },
      $root: { dot: { val: true } }
    }
  }
}, listen)
{'fraction_non_alphanumeric': 0.25257277271390766, 'fraction_numerical': 0.04851514260511614, 'mean_word_length': 1.965998256320837, 'pattern_counts': {'":': 0, '<': 8, '<?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': 1, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6926552', 'n_tokens_mistral': 1293, 'n_tokens_neox': 1156, 'n_words': 309}