8000 feat: rough benchmark · unocss/unocss@78e24ae · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Commit 78e24ae

Browse files
committed
feat: rough benchmark
1 parent 5a1182a commit 78e24ae

39 files changed

+1983
-117
lines changed

.gitignore

Lines changed: 8 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -1,81 +1,9 @@
1-
# Created by .ignore support plugin (hsz.mobi)
2-
### Node template
3-
# Logs
4-
logs
5-
*.log
6-
npm-debug.log*
7-
yarn-debug.log*
8-
yarn-error.log*
9-
10-
# Runtime data
11-
pids
12-
*.pid
13-
*.seed
14-
*.pid.lock
15-
16-
# Directory for instrumented libs generated by jscoverage/JSCover
17-
lib-cov
18-
19-
# Coverage directory used by tools like istanbul
20-
coverage
21-
22-
# nyc test coverage
23-
.nyc_output
24-
25-
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
26-
.grunt
27-
28-
# Bower dependency directory (https://bower.io/)
29-
bower_components
30-
31-
# node-waf configuration
32-
.lock-wscript
33-
34-
# Compiled binary addons (https://nodejs.org/api/addons.html)
35-
build/Release
36-
37-
# Dependency directories
38-
node_modules/
39-
jspm_packages/
40-
41-
# TypeScript v1 declaration files
42-
typings/
43-
44-
# Optional npm cache directory
45-
.npm
46-
47-
# Optional eslint cache
48-
.eslintcache
49-
50-
# Optional REPL history
51-
.node_repl_history
52-
53-
# Output of 'npm pack'
54-
*.tgz
55-
56-
# Yarn Integrity file
57-
.yarn-integrity
58-
59-
# dotenv environment variables file
60-
.env
61-
62-
# parcel-bundler cache (https://parceljs.org/)
63-
.cache
64-
65-
# next.js build output
66-
.next
67-
68-
# nuxt.js build output
69-
.nuxt
70-
71-
# Nuxt generate
1+
node_modules
2+
.DS_Store
723
dist
73-
74-
# vuepress build output
75-
.vuepress/dist
76-
77-
# Serverless directories
78-
.serverless
79-
80-
# IDE
81-
.idea
4+
dist-ssr
5+
*.local
6+
bench/fixtures/*/src
7+
!bench/fixtures/none/src
8+
bench/fixtures/none/src/Gen.vue
9+
*.log

bench/build.mjs

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
/* eslint-disable no-console */
2+
import { join } from 'path'
3+
import { promises as fs } from 'fs'
4+
import { build } from 'vite'
5+
import { targets, dir } from './meta.mjs'
6+
7+
const data = {}
8+
9+
function BuildTimePlugin(name) {
10+
let start = 0
11+
12+
return {
13+
name: 'time-log',
14+
apply: 'build',
15+
buildStart() {
16+
start = Date.now()
17+
console.time(`build:${name}`)
18+
},
19+
buildEnd() {
20+
console.timeEnd(`build:${name}`)
21+
data[name] = {
22+
time: Date.now() - start,
23+
}
24+
},
25+
async closeBundle() {
26+
const dist = join(dir, 'fixtures', name, 'dist/assets')
27+
const files = await fs.readdir(dist)
28+
let size = 0
29+
for (const file of files) {
30+
if (file.endsWith('.css')) {
31+
const stat = await fs.lstat(join(dist, file))
32+
size += stat.size
33+
}
34+
}
35+
data[name].size = size
36+
},
37+
}
38+
}
39+
40+
for (let i = 0; i < 10; i++) {
41+
console.log(`warning up... x${i + 1}`)
42+
await run('none')
43+
}
44+
45+
console.log('\n\n')
46+
47+
for (const target of targets)
48+
await run(target, true)
49+
50+
async function run(target, bench = false) {
51+
if (bench)
52+
console.log('\n----\n')
53+
const cwd = join(dir, 'fixtures', target)
54+
process.chdir(cwd)
55+
await build({
56+
root: cwd,
57+
logLevel: 'silent',
58+
plugins: bench ? [BuildTimePlugin(target)] : [],
59+
})
60+
}
61+
62+
const baseTime = data.none.time
63+
64+
Object.values(data).forEach(v => v.pureTime = v.time - baseTime)
65+
66+
console.log(data)
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<div id="app"></div>
2+
<script src="./main.js" type="module"></script>

bench/fixtures/miniwind-vue/main.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import { createApp } from 'vue'
2+
import App from './src/App.vue'
3+
4+
createApp(App).mount('#app')
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"private": true,
3+
"scripts": {
4+
"dev": "vite",
5+
"build": "vite build",
6+
"serve": "vite preview"
7+
}
8+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { defineConfig } from 'vite'
2+
import Vue from '@vitejs/plugin-vue'
3+
import Miniwind from '../../../dist/vite-vue-sfc.mjs'
4+
5+
export default defineConfig({
6+
server: {
7+
port: 3000,
8+
},
9+
plugins: [
10+
Vue(),
11+
Miniwind(),
12+
],
13+
})

bench/fixtures/miniwind/index.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<div id="app"></div>
2+
<script src="./main.js" type="module"></script>

bench/fixtures/miniwind/main.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import { createApp } from 'vue'
2+
import App from './src/App.vue'
3+
4+
createApp(App).mount('#app')

bench/fixtures/miniwind/package.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"private": true,
3+
"scripts": {
4+
"dev": "vite",
5+
"build": "vite build",
6+
"serve": "vite preview"
7+
}
8+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { defineConfig } from 'vite'
2+
import Vue from '@vitejs/plugin-vue'
3+
import Miniwind from '../../../dist/vite.mjs'
4+
5+
export default defineConfig({
6+
server: {
7+
port: 3000,
8+
},
9+
plugins: [
10+
Vue(),
11+
Miniwind(),
12+
],
13+
})

bench/fixtures/none/index.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<div id="app"></div>
2+
<script src="./main.js" type="module"></script>

bench/fixtures/none/main.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import { createApp } from 'vue'
2+
import App from './src/App.vue'
3+
4+
createApp(App).mount('#app')

bench/fixtures/none/package.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"private": true,
3+
"scripts": {
4+
"dev": "vite",
5+
"build": "vite build",
6+
"serve": "vite preview"
7+
}
8+
}

bench/fixtures/none/src/Alerts.vue

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<!--
2+
from https://tailwindcomponents.com/component/tailwind-css-alerts
3+
by @zoltanszogyenyi
4+
-->
5+
6+
<template>
7+
<div class="max-w-lg mx-auto" v-pre>
8+
<div class="flex bg-blue-100 rounded-lg p-4 mb-4 text-sm text-blue-700" role="alert">
9+
<svg class="w-5 h-5 inline mr-3" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a1 1 0 000 2v3a1 1 0 001 1h1a1 1 0 100-2v-3a1 1 0 00-1-1H9z" clip-rule="evenodd"></path></svg>
10+
<div>
11+
<span class="font-medium">Info alert!</span> Change a few things up and try submitting again.
12+
</div>
13+
</div>
14+
<div class="flex bg-red-100 rounded-lg p-4 mb-4 text-sm text-red-700" role="alert">
15+
<svg class="w-5 h-5 inline mr-3" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a1 1 0 000 2v3a1 1 0 001 1h1a1 1 0 100-2v-3a1 1 0 00-1-1H9z" clip-rule="evenodd"></path></svg>
16+
<div>
17+
<span class="font-medium">Danger alert!</span> Change a few things up and try submitting again.
18+
</div>
19+
</div>
20+
<div class="flex bg-green-100 rounded-lg p-4 mb-4 text-sm text-green-700" role="alert">
21+
<svg class="w-5 h-5 inline mr-3" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a1 1 0 000 2v3a1 1 0 001 1h1a1 1 0 100-2v-3a1 1 0 00-1-1H9z" clip-rule="evenodd"></path></svg>
22+
<div>
23+
<span class="font-medium">Success alert!</span> Change a few things up and try submitting again.
24+
</div>
25+
</div>
26+
<div class="flex bg-yellow-100 rounded-lg p-4 mb-4 text-sm text-yellow-700" role="alert">
27+
<svg class="w-5 h-5 inline mr-3" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a1 1 0 000 2v3a1 1 0 001 1h1a1 1 0 100-2v-3a1 1 0 00-1-1H9z" clip-rule="evenodd"></path></svg>
28+
<div>
29+
<span class="font-medium">Warning alert!</span> Change a few things up and try submitting again.
30+
</div>
31+
</div>
32+
<p>These alert components are part of a larger, open-source library of Tailwind CSS components. Learn more by going to the official <a class="text-blue-600 hover:underline" href="https://flowbite.com/docs/getting-started/introduction/" target="_blank">Flowbite Documentation</a>.</p>
33+
</div>
34+
</template>

bench/fixtures/none/src/App.vue

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<script setup lang="ts">
2+
import Alerts from './Alerts.vue'
3+
import Gen from './Gen.vue'
4+
</script>
5+
6+
<template>
7+
<div class="font-sans">
8+
<Alerts />
9+
<Gen />
10+
</div>
11+
</template>

bench/fixtures/none/vite.config.mjs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { defineConfig } from 'vite'
2+
import Vue from '@vitejs/plugin-vue'
3+
4+
export default defineConfig({
5+
server: {
6+
port: 3000,
7+
},
8+
plugins: [
9+
Vue(),
10+
],
11+
})
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<div id="app"></div>
2+
<script src="./main.js" type="module"></script>

bench/fixtures/tailwind-jit/main.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { createApp } from 'vue'
2+
import App from './src/App.vue'
3+
import './style.css'
4+
5+
createApp(App).mount('#app')
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"private": true,
3+
"scripts": {
4+
"dev": "vite",
5+
"build": "vite build",
6+
"serve": "vite preview"
7+
}
8+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module.exports = {
2+
plugins: {
3+
tailwindcss: {},
4+
autoprefixer: {},
5+
},
6+
}

bench/fixtures/tailwind-jit/style.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@tailwind base;
2+
@tailwind components;
3+
@tailwind utilities;
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module.exports = {
2+
mode: 'jit',
3+
purge: [
4+
'src/*.vue',
5+
],
6+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { defineConfig } from 'vite'
2+
import Vue from '@vitejs/plugin-vue'
3+
4+
export default defineConfig({
5+
server: {
6+
port: 3200,
7+
},
8+
plugins: [
9+
Vue(),
10+
],
11+
})

bench/fixtures/windicss/index.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<div id="app"></div>
2+
<script src="./main.js" type="module"></script>

bench/fixtures/windicss/main.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { createApp } from 'vue'
2+
import App from './src/App.vue'
3+
import 'virtual:windi.css'
4+
5+
createApp(App).mount('#app')

bench/fixtures/windicss/package.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"private": true,
3+
"scripts": {
4+
"dev": "vite",
5+
"build": "vite build",
6+
"serve": "vite preview"
7+
}
8+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { defineConfig } from 'vite'
2+
import Vue from '@vitejs/plugin-vue'
3+
import WindiCSS from 'vite-plugin-windicss'
4+
5+
export default defineConfig({
6+
server: {
7+
port: 3000,
8+
},
9+
plugins: [
10+
Vue(),
11+
WindiCSS(),
12+
],
13+
})

0 commit comments

Comments
 (0)
0