Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(defaults): improve component performance #16775

Merged
merged 22 commits into from Mar 14, 2023

Conversation

johnleider
Copy link
Member

@johnleider johnleider commented Feb 24, 2023

Motivation and Context

Improve framework performance

<template>
  <v-app>
    <v-container>
      <template v-for="i in length">
        <v-btn />
      </template>
    </v-container>
  </v-app>
</template>

<script setup>
  import { nextTick, onMounted, ref } from 'vue'

  const ITEMS = 1000
  const COUNT = 20
  const WARMUP_COUNT = 5
  const DELAY = 200

  const length = ref(0)

  function wait (ms) {
    return new Promise(resolve => setTimeout(resolve, ms))
  }

  onMounted(async () => {
    await wait(500)
    for (let i = 0; i < WARMUP_COUNT; i++) {
      length.value = ITEMS
      await nextTick()
      length.value = 0
      await nextTick()
    }
    requestIdleCallback(async () => {
      const result = []
      await wait(DELAY)
      for (let i = 0; i < COUNT; i++) {
        length.value = ITEMS
        const start = performance.now()
        await nextTick()
        result.push(performance.now() - start)
        await wait(DELAY)
        length.value = 0
        await nextTick()
        await wait(DELAY)
      }
      const avg = Math.round(result.reduce((a, b) => a + b, 0) / result.length)
      const sd = Math.round(Math.sqrt(result.reduce((a, b) => a + b * b, 0) / result.length - avg * avg))
      console.log(result.map(v => Math.round(v)).join('\n'))
      console.log('avg', `${avg}ms ±${sd}`)
    })
  })
</script>

@johnleider johnleider added T: enhancement Functionality that enhances existing features framework Issues and Feature Requests that have needs framework-wide. labels Feb 24, 2023
@johnleider johnleider self-assigned this Feb 24, 2023
KaelWD
KaelWD previously requested changes Feb 27, 2023
packages/vuetify/src/components/VAlert/VAlert.tsx Outdated Show resolved Hide resolved
packages/vuetify/src/components/VAlert/VAlert.tsx Outdated Show resolved Hide resolved
packages/vuetify/src/components/VAlert/VAlert.tsx Outdated Show resolved Hide resolved
@KaelWD
Copy link
Member

KaelWD commented Feb 28, 2023

yarn dev:prod

recommend incognito window or clean browser profile with no extensions installed

<template>
  <v-app>
    <v-container>
      <template v-for="i in length">
        <v-btn />
      </template>
    </v-container>
  </v-app>
</template>

<script setup>
  import { nextTick, onMounted, ref } from 'vue'

  const ITEMS = 1000
  const COUNT = 20
  const WARMUP_COUNT = 5
  const DELAY = 200

  const length = ref(0)

  function wait (ms) {
    return new Promise(resolve => setTimeout(resolve, ms))
  }

  onMounted(async () => {
    await wait(500)
    for (let i = 0; i < WARMUP_COUNT; i++) {
      length.value = ITEMS
      await nextTick()
      length.value = 0
      await nextTick()
    }
    requestIdleCallback(async () => {
      const result = []
      await wait(DELAY)
      for (let i = 0; i < COUNT; i++) {
        length.value = ITEMS
        const start = performance.now()
        await nextTick()
        result.push(performance.now() - start)
        await wait(DELAY)
        length.value = 0
        await nextTick()
        await wait(DELAY)
      }
      const avg = Math.round(result.reduce((a, b) => a + b, 0) / result.length)
      const sd = Math.round(Math.sqrt(result.reduce((a, b) => a + b * b, 0) / result.length - avg * avg))
      console.log(result.map(v => Math.round(v)).join('\n'))
      console.log('avg', `${avg}ms ±${sd}`)
    })
  })
</script>

@johnleider johnleider marked this pull request as ready for review March 6, 2023 15:45
@johnleider johnleider requested a review from KaelWD March 6, 2023 16:02
@johnleider johnleider force-pushed the refactor/component-perf-tuning branch from 4ab2841 to 74fb414 Compare March 7, 2023 17:42
@johnleider johnleider force-pushed the refactor/component-perf-tuning branch from 74fb414 to c003e6a Compare March 7, 2023 17:45
@johnleider johnleider added this to the v3.1.x milestone Mar 14, 2023
@johnleider johnleider force-pushed the refactor/component-perf-tuning branch from 83866b0 to e06c84f Compare March 14, 2023 22:19
@johnleider johnleider dismissed KaelWD’s stale review March 14, 2023 22:43

issues addressed

@johnleider johnleider changed the title refactor: improve component performance refactor(defaults): improve component performance Mar 14, 2023
@johnleider johnleider merged commit 4cd7327 into master Mar 14, 2023
19 checks passed
@johnleider johnleider deleted the refactor/component-perf-tuning branch March 14, 2023 22:44
johnleider added a commit that referenced this pull request Mar 15, 2023
fixes #16920

this is a temporary fix
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
framework Issues and Feature Requests that have needs framework-wide. T: enhancement Functionality that enhances existing features
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants