路由器配置路径“/blog/:user/:article”
文件“Article.vue”
defineComponent({
setup() {
console.log("Call setup()"); // Debug info
const route = useRoute();
const router = useRouter();
const store = useStore(); // vuex
// here omits many details.
// some axios requests depend on the variables above.
// problem come here
// this is a function bind to a table(or list) display in <template>.
// but the route must change and I need to update this component based on the row.
const rowClick = (row) => {
router.push("/blog/" …Run Code Online (Sandbox Code Playgroud) 当我为我的算法编写基准测试时,我对一个问题感到困惑!
我的测试代码详细信息已推送到 github,我将其复制到此处并添加一些注释。
https://github.com/hidstarshine/Algorithm/blob/master/leet/problem24_test.go
var TDBenchmarkSwapPairs1 *leet.ListNode
// This function may be not good, it should be init()?
func FTDBenchmarkSwapPairs1() {
TDBenchmarkSwapPairs1 = &leet.ListNode{
Val: 0,
Next: nil,
}
changeNode := TDBenchmarkSwapPairs1
for i := 1; i < 100; i++ {
changeNode.Next = &leet.ListNode{
Val: i,
Next: nil,
}
changeNode = changeNode.Next
}
}
func BenchmarkSwapPairs1(b *testing.B) {
FTDBenchmarkSwapPairs1() // problem is here
for i := 0; i < b.N; i++ {
leet.SwapPairs1(TDBenchmarkSwapPairs1)
}
}
Run Code Online (Sandbox Code Playgroud)
在问题行中,我调用FTDBenchmarkSwapPairs1(FTD表示填充测试数据)来初始化数据。
然后令人惊奇的事情发生了,BenchmarkSwapPairs1 似乎在许多 goroutine 中运行。 …