Skip to content

Instantly share code, notes, and snippets.

@rahulsom
Created November 14, 2013 06:53
Show Gist options
  • Select an option

  • Save rahulsom/7462550 to your computer and use it in GitHub Desktop.

Select an option

Save rahulsom/7462550 to your computer and use it in GitHub Desktop.
Hapi & LigthHl7Lib Performance Benchmarks
Hapi: 2.604747 ms per cycle
LightHl7Lib: 0.00451332 ms per cycle
@Grapes([
@Grab(group = 'ca.uhn.hapi', module = 'hapi-base', version = '2.0'),
@Grab(group = 'ca.uhn.hapi', module = 'hapi-structures-v26', version = '2.0'),
@Grab('org.nule:lighthl7lib:43')
])
import ca.uhn.hl7v2.parser.*
import org.nule.lighthl7lib.hl7.*
String msg = '''\
MSH|^~\\&|HIS|RIH|EKG|EKG|199904140038||ADT^A01||P|2.2
PID|0001|00009874|00001122|A00977|SMITH^JOHN^M|MOM|19581119|F|NOTREAL^LINDA^M|C|564 SPRING ST^^NEEDHAM^MA^02494^US|0002|||E|S|C|0000444444|252-00-4414||||SA|||SA||||NONE|V1|0001||D.ER^50A^M110^01|ER|P00055|11B^M011^02|070615^BATMAN^GEORGE^L|555888^NOTREAL^BOB^K^DR^MD|777889^NOTREAL^SAM^T^DR^MD^PHD|ER|D.WT^1A^M010^01|||ER|AMB|02|070615^NOTREAL^BILL^L|ER|000001916994|D||||||||||||||||GDD|WA|NORM|02|O|02|E.IN^02D^M090^01|E.IN^01D^M080^01|199904072124|199904101200|199904101200||||5555112333|||666097^NOTREAL^MANNY^P
NK1|0222555|NOTREAL^JAMES^R|FA|STREET^OTHER STREET^CITY^ST^55566|||||||||ORGANIZATION
PV1|0001|I|D.ER^1F^M950^01|ER|P000998|11B^M011^02|070615^BATMAN^GEORGE^L|555888^OKNEL^BOB^K^DR^MD|777889^NOTREAL^SAM^T^DR^MD^PHD|ER|D.WT^1A^M010^01|||ER|AMB|02|070615^VOICE^BILL^L|ER|000001916994|D||||||||||||||||GDD|WA|NORM|02|O|02|E.IN^02D^M090^01|E.IN^01D^M080^01|199904072124|199904101200|||||5555112333|||666097^DNOTREAL^MANNY^P
PV2|||0112^TESTING|55555^PATIENT IS NORMAL|NONE|||19990225|19990226|1|1|TESTING|555888^NOTREAL^BOB^K^DR^MD||||||||||PROD^003^099|02|ER||NONE|19990225|19990223|19990316|NONE
AL1||SEV|001^POLLEN
GT1||0222PL|NOTREAL^BOB^B||STREET^OTHER STREET^CITY^ST^77787||||||MO|111-33-5555||||NOTREAL GILL N|STREET^OTHER STREET^CITY^ST^99999|
IN1||022254P|4558PD|BLUE CROSS|STREET^OTHER STREET^CITY^ST^00990||||221K|LENIX|||19980515|19990515|||PATIENT01 TEST D||||||||||||||||||02LL|022LP554'''.replace('\n','\r')
def canonicalModelClassFactory = new CanonicalModelClassFactory("2.6")
def parser = new PipeParser(canonicalModelClassFactory)
def time(Closure c) {
long start = System.nanoTime()
c()
long end = System.nanoTime()
(end -start)/1000000.0
}
def hapi = time {
10000.times {
def m = parser.parse(msg)
m.encode()
m.generateACK().encode()
}
} / 10000.0
println "Hapi: $hapi ms per cycle"
def lightHl7Lib = time {
100000.times {
def r = new Hl7Record(msg)
r.rebuild()
}
} / 100000.0
println "LightHl7Lib: $lightHl7Lib ms per cycle"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment