Skip to content

Instantly share code, notes, and snippets.

@justinfx
Created December 16, 2014 10:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save justinfx/9c07ce03693f03c4bc46 to your computer and use it in GitHub Desktop.
Save justinfx/9c07ce03693f03c4bc46 to your computer and use it in GitHub Desktop.
Some basic benchmarks of fileseq vs gofileseq vs seqls
package main
import (
"github.com/justinfx/gofileseq"
"testing"
)
func BenchmarkGoSeq10(b *testing.B) {
var res fileseq.FileSequences
var err error
for x := 0; x < b.N; x++ {
res, err = fileseq.FindSequencesOnDisk("seq10")
if err != nil || len(res) == 0 {
panic("Empty")
}
}
}
func BenchmarkGoSeq100(b *testing.B) {
var res fileseq.FileSequences
var err error
for x := 0; x < b.N; x++ {
res, err = fileseq.FindSequencesOnDisk("seq100")
if err != nil || len(res) == 0 {
panic("Empty")
}
}
}
func BenchmarkGoSeq500(b *testing.B) {
var res fileseq.FileSequences
var err error
for x := 0; x < b.N; x++ {
res, err = fileseq.FindSequencesOnDisk("seq500")
if err != nil || len(res) == 0 {
panic("Empty")
}
}
}
func BenchmarkGoSeq1000(b *testing.B) {
var res fileseq.FileSequences
var err error
for x := 0; x < b.N; x++ {
res, err = fileseq.FindSequencesOnDisk("seq1000")
if err != nil || len(res) == 0 {
panic("Empty")
}
}
}
func BenchmarkGoSeq25000(b *testing.B) {
var res fileseq.FileSequences
var err error
for x := 0; x < b.N; x++ {
res, err = fileseq.FindSequencesOnDisk("seq25000")
if err != nil || len(res) == 0 {
panic("Empty")
}
}
}
func BenchmarkGoSeq100_x10(b *testing.B) {
var res fileseq.FileSequences
var err error
for x := 0; x < b.N; x++ {
res, err = fileseq.FindSequencesOnDisk("seq100_x10")
if err != nil || len(res) == 0 {
panic("Empty")
}
}
}
func BenchmarkGoSeq100_x100(b *testing.B) {
var res fileseq.FileSequences
var err error
for x := 0; x < b.N; x++ {
res, err = fileseq.FindSequencesOnDisk("seq100_x100")
if err != nil || len(res) == 0 {
panic("Empty")
}
}
}
var All = []string{"seq10", "seq100", "seq500", "seq1000",
"seq25000", "seq100_x10", "seq100_x100"}
func BenchmarkGoAll(b *testing.B) {
var res fileseq.FileSequences
var err error
for x := 0; x < b.N; x++ {
for _, s := range All {
res, err = fileseq.FindSequencesOnDisk(s)
if err != nil || len(res) == 0 {
panic("Empty")
}
}
}
}
import fileseq
def test(seq):
res = fileseq.findSequencesOnDisk(seq)
assert len(res)
seqs = (
"seq10", "seq100", "seq500", "seq1000",
"seq25000", "seq100_x10", "seq100_x100"
)
def test_all():
for s in seqs:
res = fileseq.findSequencesOnDisk(s)
assert len(res)
print "seq10: ",
%timeit -n 2500 -r 1 test("seq10")
print "seq100: ",
%timeit -n 500 -r 1 test("seq100")
print "seq500: ",
%timeit -n 500 -r 1 test("seq500")
print "seq1000: ",
%timeit -n 100 -r 1 test("seq1000")
print "seq25000:",
%timeit -n 5 -r 1 test("seq25000")
print "seq100_x10: ",
%timeit -n 50 -r 1 test("seq100_x10")
print "seq100_x100: ",
%timeit -n 10 -r 1 test("seq100_x100")
print "all: ",
%timeit -n 10 -r 1 test_all()
# https://pypi.python.org/pypi/Fileseq/0.5.1
# https://github.com/justinfx/gofileseq
#
# Seq10 - A sequence of 10 frames
# Seq100_x100 - 100 sequences of 100 frames in a single directory
BenchmarkPySeq10 0.283 ms
BenchmarkGoSeq10 0.174 ms
BenchmarkPySeq100 2.020 ms
BenchmarkGoSeq100 0.983 ms
BenchmarkPySeq500 9.710 ms
BenchmarkGoSeq500 4.645 ms
BenchmarkPySeq1000 19.400 ms
BenchmarkGoSeq1000 9.394 ms
BenchmarkPySeq25000 508.0 ms
BenchmarkGoSeq25000 261.1 ms
BenchmarkPySeq100_x10 20.80 ms
BenchmarkGoSeq100_x10 10.73 ms
BenchmarkPySeq100_x100 218.0 ms
BenchmarkGoSeq100_x100 114.2 ms
BenchmarkPyAll 782.0 ms
BenchmarkGoAll 402.7 ms
# time seqls -r &> /dev/null
BenchmarkSeqlsAll 289.0 ms
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment