-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I found excelize(golang) is 2~3 times slower than js-xlsx #439
Comments
Does |
Actually var workbook = XLSX.readFile(excelPath); // this code is already finished parse. Because even I uncomment the original code, Time Cost Not Changed ! |
I’ll have to try the benchmarks out. We’ve had a few passes to improve the performance of the library but there is probably plenty of work that could be done as a community. Using Go benchmarks and the profiler could help highlight the slowest areas. Also, many Node libraries are hooked up to some pretty efficient C libraries under the hood. |
I had a pretty big excel file on hand so I went ahead and tried things out, here are my benchmark files: package main
import (
"fmt"
"time"
"github.com/360EntSecGroup-Skylar/excelize"
)
func main() {
excelPath := "data.xlsx"
timeStart := time.Now()
times := 5
for i := 0; i < times; i++ {
f, _ := excelize.OpenFile(excelPath)
rows, _ := f.Rows("DTAs")
for rows.Next() {
row := rows.Columns()
for i := range row {
if i >= 0 {
continue
}
}
}
}
fmt.Println(time.Since(timeStart).Seconds())
} const XLSX = require('xlsx');
function run() {
let currentMilliSec = Date.now()
let times = 5
let excelPath = "data.xlsx"
for (let i = 0; i < times; i++) {
var workbook = XLSX.readFile(excelPath);
let sheet = workbook.Sheets["DTAs"];
}
let after = Date.now()
console.log("js cost: ", after - currentMilliSec, "ms")
}
run() The go example ran in 17 seconds, the js example ran in 20 seconds, which puts them at roughly even. If I use |
I just noticed I ran the benchmarks against 1.4.1. If I switch the import to |
For fun I moved this to a benchmark:
Then ran it with the profilers enabled:
CPU profile results:
Memory:
It looks like the vast majority of our time is spent the standard library's xml decoder. |
We were parsing the whole sheet twice since the sheet reader already reads in all the rows. getTotalRowsCols function is unused after these changes so it has been deleted as well. Closes qax-os#439
Instead of re-encoding the full sheet to change the namespaces in the encoded bytes, read the sheet again and do the byte replacements there. In this case, file access ends up being more performant than marshaling the sheet back to XML. In the SharedStrings test, ensure the strings are actually read. Fix qax-os#439
Platform: Windows 10
go version go1.12.4 windows/amd64
node version v8.11.1
Maybe there is some problem with my usage?
code is here:
The text was updated successfully, but these errors were encountered: