From: Haejoong L. <hae...@un...> - 2002-03-14 03:33:38
|
You are a valuable user :) You are totally correct, and we are well aware of the bottleneck. One of our application project based on agtk is very serious about the problem. On the one hand, we are trying to reduce the number of library calls by adding functions that can do many things by one call. On the other hand, we will definitely have to pursue what you suggest. I remember I gave up direct wrapping because it didn't go smooth. I guess it's time to try again. Haejoong On Thu, Mar 14, 2002 at 11:38:21AM +1100, Steve Cassidy wrote: > Hi folks, Steve the whiner here again... > > we've just hit some major inneficiencies in the tcl interface to AG, this > came when we tried to draw a real annotation in our new labeller and it took > 1000 seconds to complete 250 annotations. The bottleneck turned out to be > calls to the AG routines to get anchor times, specifically: > > [::AG_GetAnchorOffset [::AG_GetStartAnchor $entry]] > > > To get some figures I wrote a short tcl script which creates an annotation > (copied from ag_wrapper_test.tcl) and then times calls to the above fns. The > script is attached but the output is: > > tclsh timer.tcl > getting start times for 3 nodes > [::AG_GetAnchorOffset [::AG_GetStartAnchor $entry]]: 10650 microseconds per > teration > [::AG_GetStartAnchor $entry]: 6104 microseconds per iteration > > for comparison I wrote a similar script using Emu, accessing the same kind of > information (start/end times) which is stored in the same way (as a member > variable in a C++ class): > > getting start times for 5 nodes > 232 microseconds per iteration > > This is a significant overhead which is going to make writing useable user > interfaces difficult if it is reflected accross the API as I suspect. > > I haven't compared these times to a raw C++ version but I'm hoping that that > would be significantly faster and that the bottleneck is in the wrapper code. > > Looking at the code it seems that there is a lot of indirection in the > scripting wrapper that could probably be avoided. SWIG can take care of > converting things to strings if needs be. I wonder if we shouldn't look at > how this is done and perhaps have another bash at the wrapper interface. > > I note that all the interfaces in AGAPI.h are in terms of strings so a simple > SWIG wrap of AGAPI.h might well work -- was this tried? > > We're working on another SWIG project here at the moment (wrapping the > Edinburgh speech tools) and so it might be worth our looking at this again at > the same time while we still understand SWIG! > > Comments welcomed. > > Steve > > # ag_wrapper_test.tcl > # Haejoong Lee > # Copyright (C) 2001 Linguistic Data Consortium, U Penn. > # Web: http://www.ldc.upenn.edu/; Email: ld...@ld... > # For license information, see the file `LICENSE' included > # with the distribution. > > > source ../ag_wrapper/tcl/ag.tcl > load ../ag_wrapper/tcl/.libs/ag_tcl.so > > set agsetId [AG_CreateAGSet "TIMIT"] > set timelineId [AG_CreateTimeline $agsetId] > AG_SetFeature $timelineId "length" "30 min" > set signalIds [AG_CreateSignal $timelineId "test_uri" "test_mimeclass" "test_mimetype" "test_encoding" "test_unit" "test_track"] > set agId [AG_CreateAG $agsetId $timelineId] > > set anchor1 [AG_CreateAnchor $agId 10 "sec" $signalIds] > set anchor2 [AG_CreateAnchor $agId 20 "sec" $signalIds] > set anchor3 [AG_CreateAnchor $agId 30 "sec" $signalIds] > set annotation1 [AG_CreateAnnotation $agId $anchor1 $anchor2 "timit"] > set annotation2 [AG_CreateAnnotation $agId $anchor2 $anchor3 "timit"] > set annotation3 [AG_CreateAnnotation $agId $anchor1 $anchor3 "timit"] > AG_SetFeature $annotation1 "sentence" "It's raining." > AG_SetFeature $annotation2 "sentence" "We'll see you around 8 o'clock." > > > > puts "getting start times for [llength [::AG_GetAnnotationSeqByOffset $agId]] nodes" > > puts -nonewline {[::AG_GetAnchorOffset [::AG_GetStartAnchor $entry]]: } > puts [time { > foreach entry [::AG_GetAnnotationSeqByOffset $agId] { > set x [::AG_GetAnchorOffset [::AG_GetStartAnchor $entry]] > } > } 1000] > > puts -nonewline {[::AG_GetStartAnchor $entry]: } > puts [time { > foreach entry [::AG_GetAnnotationSeqByOffset $agId] { > set x [::AG_GetStartAnchor $entry] > } > } 1000] > > > > > > emutemplate tpl demo > > tpl hierarchy h msdjc001 > > puts "getting start times for [llength [h segments Phonetic]] nodes" > > puts [time { > foreach s [h segments Phonetic] { > set x [h seginfo $s times] > } > } 1000] |