Skip to content

Commit

Permalink
bench: allow benchmarking components without <script>;
Browse files Browse the repository at this point in the history
bench: add Hello.vue as a benchable component
  • Loading branch information
phoenix-ru committed Jan 17, 2024
1 parent dda1f55 commit 9b4d6e7
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 7 deletions.
12 changes: 12 additions & 0 deletions crates/fervid/benches/fixtures/Hello.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<template>
<h1>
Hello {{ name }}!
</h1>
<input v-model="name">
</template>

<script setup>
import { ref } from 'vue'
const name = ref('fervid')
</script>
22 changes: 15 additions & 7 deletions crates/fervid_napi/benchmark/bench.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import kleur from 'kleur'
import { readFileSync } from 'node:fs'
import { join } from 'node:path'
import { cpus } from 'node:os'
import { compileScript, parse } from '@vue/compiler-sfc'
import { compileScript, compileTemplate, parse } from '@vue/compiler-sfc'

import { Compiler } from '../index'

Expand All @@ -26,12 +26,20 @@ async function run() {

b.add('@vue/compiler-sfc', () => {
const descriptor = parse(input, { filename: 'input.vue' })
compileScript(descriptor.descriptor, {
id: 'abc',
isProd: true,
inlineTemplate: true,
defineModel: true
})
if (descriptor.descriptor.script || descriptor.descriptor.scriptSetup) {
compileScript(descriptor.descriptor, {
id: 'abc',
isProd: true,
inlineTemplate: true,
defineModel: true
})
} else {
compileTemplate({
source: descriptor.descriptor.source,
filename: 'input.vue',
id: 'abc'
})
}
}),

b.add('@fervid/napi sync', () => {
Expand Down

0 comments on commit 9b4d6e7

Please sign in to comment.