Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Can i speed this up ??
Message
From
06/07/2006 23:47:33
Suhas Hegde
Dental Surgeon
Sirsi, India
 
 
To
06/07/2006 13:53:25
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
01134026
Message ID:
01134350
Views:
27
>My first idea will only bring speedup if in the records in SCAN NEXT 80 there are
>quite a few duplicate high/low pairings, for instance
>10 times high 100, low 60
>08 times high 100, low 65
>
>and so on.
>
>If that is the case, check if
>lnMagic = 80
>select high, low, count(*) as r_cnt ;
>   from (this.alias_name) ;
>   where between(recno(), m.nCount, m.nCount+m.lnMagic) ;
>   group by 1,2 ;
>   into cursor t_from
>
>lnRecPairs = _Tally
>
>scan
>  replace f2 WITH f2+r_cnt ;
>      FOR BETWEEN(foo.f1, t_from.low, t_from.high) ;
>      IN foo
>endscan
>? m.lnMagic - m.lnRecPairs," operations saved"
>saves enough replace cycles to balance the added sql before.
>
>Try also adding Craig's idea of using seek/replace while instead of replace for - in most multiuser situations I believe this would be the best way. Since you are working on a cursor I am not sure if vfp has not some added caching tricks, since the cdx is guaranteed to be "clean". Another option might be to set deleted off before and on after the part, as these records should always be there and some more cpu cycles could be saved.
>
>>this code runs when ever the ncount is changed.... think like it is for scrolling of a graph ... there is a glitch in the smooth movement .... this process shows a average of 0.5 sec the maximum in the whole class other process including paint of the graph takes 0.07 secs.. so i though is there a faster was to do this ???
>
>If it is as you describe(some kind of derivative from movings average as from the last 80 days of stock market range) then you should save your cursor "foo", subtract the very last record (nCount+80) and add the data from nCount: the rest should still be the same and all those cycles saved <g>. The records nCount to nCount +79 should be nCount+1 and nCount+80 in the next iteration, so use the already calculated sums for them. You could speed up to a runtime of perhaps 1% of the original time <bg>. Something like (all code NON tested, the lnOld -values you will have to take care for yourself in your code structure)
lparameter ncount
>local ncount, llCreate
>
>if !used('foo')
>        llCreate = .t.
>	CREATE CURSOR foo (f1 n(20,2),f2 i)
>endif
>if not m.llCreate and this.highlow1.ymin=lnOldyMin and this.highlow1.ymax= lnOldyMax
>  SELECT (this.alias_name)
>  GOTO ncount
>  high = high
>  low = low
>  replace f2 WITH f2+1 FOR BETWEEN(foo.f1,m.low,m.high) IN foo
>
>  GOTO ncount+81
>  high = high
>  low = low
>  replace f2 WITH f2-1 FOR BETWEEN(foo.f1,m.low,m.high) IN foo
>
>else
>
>  select foo
>  if reccount()>0
>     zap
>  endif
>  FOR m.xi = this.highlow1.ymin TO this.highlow1.ymax STEP (ROUND((this.highlow1.ymin+this.highlow1.ymax)/2,0)*0.1)/100
>        	INSERT INTO foo (f1) values(m.xi)
>  NEXT
>  SELECT foo
>  INDEX ON f1 TAG f1
>
>
>  SELECT (this.alias_name)
>  GOTO ncount
>  SCAN NEXT 80
>	        m.high = high
>        	m.low = low
>*	        replace f2 WITH f2+1 FOR foo.f1 >= m.low and foo.f1 <= m.high IN foo
>        	replace f2 WITH f2+1 FOR BETWEEN(foo.f1,m.low,m.high) IN foo
>  ENDSCAN
>endif
>regards
>
>thomas


hi,
Yes , this is for the stock market application i am using for my personal ends. It is a new parameter called Noise of the data ... the most number of price ranges in the period... I even thought abt adding the whole years data and saving the cursor but it kills the basic logic of the noise for the period ....

also in case i do use it by having many cursors like each for the 80 values... there would be lot of unnecessary over head suppose 400 records ??? then the number of cursors would be 400-80 = 320....

suhashegde
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform