<commit_before>import moer, { Element, connect } from '../../index'

const valuePoints = [
  'Daenerys', 'Jon', 'Sansa', 'Arya', 'Stannis', 'Gregor', 'Tyrion',
  'Theon', 'Joffrey', 'Ramsay', 'Cersei', 'Bran', 'Margaery',
  'Melisandre', 'Daario', 'Jamie', 'Eddard', 'Myrcella', 'Robb',
  'Jorah', 'Petyr', 'Tommen', 'Sandor', 'Oberyn', 'Drogo', 'Ygritte'
]

const ROWS = 1000
const COLS = 10
const grid = generateGrid(ROWS, COLS)
const s = window.performance.now()

@connect
class Index extends Element {
  state = {
    cols: COLS,
    rows: ROWS,
    grid: grid,
    dataPoints: grid.length * grid[0].items.length,
    filter: ''
  }
  matches (item) {
    return item.value.toLowerCase().indexOf(this.state.filter.toLowerCase()) > -1
  }
  visibleCount () {
    let count = 0
    for (const items of this.stat.grid) {
      for (const item of items) {
        if (!this.state.filter || this.matches(item)) count++
      }
    }
    return count
  }
  unmount = () => {
    console.profile('unmount')
    const s = window.performance.now()
    this.state.grid = []
    setTimeout(() => {
      this.store.msg = 'umount took: ' + (window.performance.now() - s).toFixed(2) + 'ms'
      console.profileEnd('unmount')
    }, 0)
  }
  rerender = () => {
    const grid = generateGrid(1000, 10)
    const s = window.performance.now()
    console.profile('rerender')
    this.state.grid = grid
    setTimeout(() => {
      this.store.msg = 'rerender took: ' + (window.performance.now() - s).toFixed(2) + 'ms'
      console.profileEnd('rerender')
    }, 0)
  }
  render (d) {
    return () => {
      d.div(); {
        d.h1(); 'Rendering Dynamic Big Table'
        d.p(); {
          'Reference: '
          d.a({ href: 'http://insin.github.io/ui-lib-samples/large-datasets/index.html' }); 'insin/ui-lib-samples/large-datasets'
        }
        d.p(); {
          d.span(); `${this.state.rows} x ${this.state.cols}. ${this.store.msg}`
        }
        d.p(); {
          d.button({ onClick: this.unmount }); 'Unmount'
          d.button({ onClick: this.rerender }); 'Rerender with fresh data'
        }
        d.form(); {
          d.strong(); 'Filter Data:'
          d.input({ type: 'text', onInput: e => (this.state.filter = e.target.value) }); {}
          if (this.state.filter) {<commit_msg>调整性能测试不正确的地方<commit_after>import moer, { Element, connect } from '../../index'

const valuePoints = [
  'Daenerys', 'Jon', 'Sansa', 'Arya', 'Stannis', 'Gregor', 'Tyrion',
  'Theon', 'Joffrey', 'Ramsay', 'Cersei', 'Bran', 'Margaery',
  'Melisandre', 'Daario', 'Jamie', 'Eddard', 'Myrcella', 'Robb',
  'Jorah', 'Petyr', 'Tommen', 'Sandor', 'Oberyn', 'Drogo', 'Ygritte'
]

const ROWS = 1000
const COLS = 10
const grid = generateGrid(ROWS, COLS)
const s = window.performance.now()

@connect
class Index extends Element {
  state = {
    cols: COLS,
    rows: ROWS,
    grid: grid,
    dataPoints: grid.length * grid[0].items.length,
    filter: ''
  }
  matches (item) {
    return item.value.toLowerCase().indexOf(this.state.filter.toLowerCase()) > -1
  }
  visibleCount () {
    let count = 0
    for (const items of this.stat.grid) {
      for (const item of items) {
        if (!this.state.filter || this.matches(item)) count++
      }
    }
    return count
  }
  unmount = () => {
    console.profile('unmount')
    const s = window.performance.now()
    this.state.grid = []
    setTimeout(() => {
      this.store.msg = 'umount took: ' + (window.performance.now() - s).toFixed(2) + 'ms'
      console.profileEnd('unmount')
    }, 0)
  }
  rerender = () => {
    const grid = generateGrid(1000, 10)
    const s = window.performance.now()
    console.profile('rerender')
    this.state.grid = grid
    setTimeout(() => {
      this.store.msg = 'rerender took: ' + (window.performance.now() - s - 1).toFixed(2) + 'ms'
      console.profileEnd('rerender')
    }, 1)
  }
  render (d) {
    return () => {
      d.div(); {
        d.h1(); 'Rendering Dynamic Big Table'
        d.p(); {
          'Reference: '
          d.a({ href: 'http://insin.github.io/ui-lib-samples/large-datasets/index.html' }); 'insin/ui-lib-samples/large-datasets'
        }
        d.p(); {
          d.span(); `${this.state.rows} x ${this.state.cols}. ${this.store.msg}`
        }
        d.p(); {
          d.button({ onClick: this.unmount }); 'Unmount'
          d.button({ onClick: this.rerender }); 'Rerender with fresh data'
        }
        d.form(); {
          d.strong(); 'Filter Data:'
          d.input({ type: 'text', onInput: e => (this.state.filter = e.target.value) }); {}
          if (this.state.filter) {
{'fraction_non_alphanumeric': 0.1899891186071817, 'fraction_numerical': 0.008922742110990207, 'mean_word_length': 2.5083969465648854, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 17, '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': '7032056', 'n_tokens_mistral': 1667, 'n_tokens_neox': 1636, 'n_words': 339}