1 Star 0 Fork 1

窦雪峰 / unioffice

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
main.go 1.17 KB
一键复制 编辑 原始数据 按行查看 历史
Todd 提交于 2017-09-15 17:44 . meta: add performance numbers
// Copyright 2017 Baliance. All rights reserved.
package main
import (
"flag"
"fmt"
"log"
"os"
"runtime/pprof"
"time"
"baliance.com/gooxml/spreadsheet"
)
var cpuprofile = flag.String("cpuprofile", "", "write cpu profile to file")
func main() {
flag.Parse()
if *cpuprofile != "" {
f, err := os.Create(*cpuprofile)
if err != nil {
log.Fatal(err)
}
pprof.StartCPUProfile(f)
defer pprof.StopCPUProfile()
}
start := time.Now()
ss := spreadsheet.New()
nRows := 30000
nCols := 100
sheet := ss.AddSheet()
// rows
for r := 0; r < nRows; r++ {
row := sheet.AddRow()
// and cells
for c := 0; c < nCols; c++ {
cell := row.AddCell()
cell.SetNumber(float64(r + c))
}
}
if err := ss.Validate(); err != nil {
log.Fatalf("error validating sheet: %s", err)
}
fmt.Printf("creating %d rows * %d cells took %s\n", nRows, nCols, time.Now().Sub(start))
ss.SaveToFile("lots-of-rows.xlsx")
start = time.Now()
fmt.Printf("saving took %s\n", time.Now().Sub(start))
start = time.Now()
_, err := spreadsheet.Open("lots-of-rows.xlsx")
if err != nil {
log.Fatalf("error opening sheet: %s", err)
}
fmt.Printf("reading took %s\n", time.Now().Sub(start))
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/douxuefeng/unioffice.git
git@gitee.com:douxuefeng/unioffice.git
douxuefeng
unioffice
unioffice
v0.3.0

搜索帮助

344bd9b3 5694891 D2dac590 5694891