Skip to content

Instantly share code, notes, and snippets.

@nsf
Created September 14, 2010 02:50
Show Gist options
  • Select an option

  • Save nsf/578445 to your computer and use it in GitHub Desktop.

Select an option

Save nsf/578445 to your computer and use it in GitHub Desktop.
package main
import "fmt"
type TableEntry struct {
exectype string
on int
on2 int
on3 int
}
const header = `
┌─────────────────┬───────────┬───────────┬───────────┐
│ Exec Type │ O(n) │ O(n²) │ O(n³) │
├─────────────────┼───────────┼───────────┼───────────┤
`
const footer = `
└─────────────────┴───────────┴───────────┴───────────┘
`
func WriteTable(entries []TableEntry) {
fmt.Print(header[1:])
for _, e := range entries {
fmt.Printf("│ %-15s │ %9d │ %9d │ %9d │\n", e.exectype, e.on, e.on2, e.on3)
}
fmt.Print(footer[1:])
}
func main() {
table := []TableEntry{
TableEntry{"1 Thread", 56456, 253235, 5345345},
TableEntry{"2 Thread", 12414, 436367, 3463456},
TableEntry{"3 Thread", 34965, 767565, 9986564},
}
WriteTable(table)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment