Hi Bruce,
I'm using jFiles/nettalk webservices quite intensively and now I am into the speed "thingy". I have to deal with tremendous amounts of rather large requests and optimised my appliction and backend interaction as much as possible.
As jFiles ships with source I can look for improvements there too, (and you've probably guessed it
so I did ... I've attached the modified 1.26 version, hope you will consider implementing these adjustments and suggestions below
some requests and/or suggestions (not applied to the attached source <g>):
1 - something I haven't tried, but only thought of: is it a good idea to create one toplevel object as a container for most of jsonclass properties in one one place? Then each created jsonclass object will need a reference to this toplevel object. But this would probably create less overhead than all the cloning and cascading (up/down) of the properties for each object. The objects themselves can be smaller, so construction them runs faster. Again I don't grasp the concept of jFiles completely and I'm only thinking out loud :-)
2 - the general loading/parsing of the json file contains quite a lot of calls to the .HandleChar procedure, but since version 1.25 (?) you've added a third parameter pPlace that is filled with a call to substr() for each call. I haven't changed these the attached version, but stripping them out improves the call to the LoadString method with another 4 to 5 percent speed improvement. Maybe passing the pToParse String by reference and only substr it when an error occurs (which should be rarely the case ...)?
3 - would you consider removing (or making it a configurable object property (with the downside of cascading ...)?) the calls to SELF.Trace in at least both the .FillStructure method and the .GetObject (when no object is found) method?. I prefer to ship all my code with debug option on, so these calls are effectively made in the production system and do slowdown the system (on the 5000 record example this saves me .3 secs per request)
Now for the applied improvement (see attached modified jFiles.clw/inc)
when loading json into a queue I noticed the fieldlabels are processed for each queue record/json object. I've created a "preprocessor" for this, with little or no overhead that reduces a total processing time of 5000 records from 2.24 secs to 1.95 secs (this is total "service time", so includes api validition, fetching against backend of 5000 records, and producing a 5000 record result queue and turning that into json too)
the following needs to be changed:
- in jfiles.inc : add the ColNameQType declaration
- in jfiles.inc : modify the prototype of the first Fillstructure item to : FillStructure procedure(*GROUP pGroup, <ColNameQType pColNameQ>),Long,Proc,VIRTUAL
- in files.clw : in the FillStructure (first occur.) method the following is added (see around line 1539):
if ~OMITTED(pColNameQ)
GET(pColNameQ, c)
nIndex = SELF.Position(pColNameQ.label)
!? self.trace(all(' ',indent) & 'Trying to fill ' & clip(pColNameQ.label) & ' nIndex = ' & nIndex )
else
PropertyName.SetValue(WHO(pGroup,c))
self.AdjustFieldName(PropertyName,self.TagCase)
nIndex = SELF.Position(PropertyName.GetValue())
!? self.trace(all(' ',indent) & 'Trying to fill ' & clip(PropertyName.GetValue()) & ' nIndex = ' & nIndex )
end
- in jFiles.clw the method "JSONClass.load Procedure(QUEUE pQueue)" is modified: this does the actual preprocessing and passes the local queue to the .FillStructure method
There is also another FillStructure method that's called with a queue as a parameter (second occurence), that I haven't touched (as I don't effectively use it), but that might also benefit from this!
Hope you have time to implement (at least some of it). Let me know if I can be of any help. I'm willing to invest some time in it too!
regards,
Ton