Skip to content

Commit

Permalink
meta: add performance numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
tbaliance committed Sep 15, 2017
1 parent 199db80 commit fe93d10
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 1 deletion.
20 changes: 19 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
**gooxml** is a library for creation of Office Open XML documents (.docx, .xlsx
and .pptx).
and .pptx). It's goal is to be the most compatible and highest performance Go
library for creation and editing of docx/xlsx/pptx files.


[![Build Status](https://travis-ci.org/baliance/gooxml.svg?branch=master)](https://travis-ci.org/baliance/gooxml)
[![GitHub (pre-)release](https://img.shields.io/github/release/baliance/gooxml/all.svg)](https://github.com/baliance/gooxml/releases)
Expand All @@ -17,6 +19,22 @@ and .pptx).
prototype code is checked in but it will be reworked once docx/xlsx are
'finished'.

## Performance ##

There has been a great deal of interest in performance numbers for spreadsheet
creation/reading lately, so here are gooxml numbers for this
[benchmark](https://github.com/baliance/gooxml/tree/master/_examples/spreadsheet/lots-of-rows)
which creates a sheet with 30k rows, each with 100 columns.

creating 30000 rows * 100 cells took 3.92506863s
saving took 89ns
reading took 9.522383048s

Creation is fairly fast, saving is very quick due to no reflection usage, and
reading is a bit slower. The downside is that the binary is large (33MB) as it
contains generated structs, serialization and deserialization code for all of
DOCX/XLSX/PPTX.

## Current Work

The current work being performed is the implementation of a spreadsheet formula
Expand Down
60 changes: 60 additions & 0 deletions _examples/spreadsheet/lots-of-rows/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
// 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))
}

0 comments on commit fe93d10

Please sign in to comment.