提交 e00da37c 编写于 作者: Q qq_38870145

Wed May 15 09:37:00 CST 2024 inscode

上级 4735d8e5
...@@ -10,10 +10,10 @@ import "dayjs/locale/zh-cn"; ...@@ -10,10 +10,10 @@ import "dayjs/locale/zh-cn";
import { useStore } from "vuex"; import { useStore } from "vuex";
import {WebPerformance} from 'web-performance-tool'; import {WebPerformance} from 'web-performance-tool';
onMounted(()=>{ onMounted(()=>{
const WebPerformanceInstance=new WebPerformance(); // const WebPerformanceInstance=new WebPerformance();
// 计算性能 // // 计算性能
WebPerformanceInstance.calcPerformance(); // WebPerformanceInstance.calcPerformance();
console.log('性能指标:',WebPerformanceInstance.getPerformance()) // console.log('性能指标:',WebPerformanceInstance.getPerformance())
}) })
dayjs.locale("zh-cn"); dayjs.locale("zh-cn");
......
<script setup> <script setup>
import {reactive,onMounted} from 'vue' import { reactive, onMounted, onBeforeMount } from 'vue'
import CommitLine from './commit/index.vue' import CommitLine from './commit/index.vue'
import ArticleBar from './article/index.vue' import ArticleBar from './article/index.vue'
import Author from '../Author.vue' import Author from '../Author.vue'
import HubPie from './hub/index.vue' import HubPie from './hub/index.vue'
import {articleData} from './data/data.js' import { articleData } from './data/data.js'
const state=reactive({ const state = reactive({
title:'', title: '',
articleData:[] articleData: [],
}) echartDuration: 0,
})
const getRenderBarData= ()=>{ const getRenderBarData = () => {
state.articleData=[...articleData] state.articleData = [...articleData]
state.articleData.sort((a,b)=>new Date(a.postTime)-new Date(b.postTime)) state.articleData.sort((a, b) => new Date(a.postTime) - new Date(b.postTime))
} }
onMounted(()=>{ onBeforeMount(() => {
getRenderBarData() // 标记开始时刻
}) performance.mark('render-echart1-start')
})
onMounted(() => {
getRenderBarData()
// 标记开始时刻
performance.mark('render-echart1-end')
const measure = performance.measure('render-echart-duration', 'render-echart1-start', 'render-echart1-end')
console.log('measure', measure)
console.log('measure type', typeof measure)
const duration = measure.duration
console.log('duration', duration)
state.echartDuration = duration.toFixed(2)
})
</script> </script>
<template> <template>
<div style="padding:20px;"> <div style="padding:20px;">
<!-- <Author/> --> <!-- <Author/> -->
<div> <div>
{{state.title}} {{ state.title }}
<div> <div>
<CommitLine /> <CommitLine />
<ArticleBar :tableData="state.articleData" /> <ArticleBar :tableData="state.articleData" />
<HubPie /> <HubPie />
</div> </div>
<div>
渲染耗时:{{ state.echartDuration }} ms
</div>
</div> </div>
</div> </div>
</template> </template>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册