Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Parallel Fox: Performance Not Increased Greatly
Message
 
To
27/01/2014 12:44:21
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows 8
Network:
Windows XP
Database:
Visual FoxPro
Application:
Desktop
Miscellaneous
Thread ID:
01592451
Message ID:
01592453
Views:
115
Harsh, I've never used ParallelFox, but there is something that does not look good to me in your code, like setting the worker count and binding the events inside the scan loop, and also I would set the number of workers before starting them, seems more reasonable, the MainProcess would look like this:
PROCEDURE Mainprocess
	Local Parallel as Parallel
	
	Parallel = NewObject("Parallel", "ParallelFox.vcx")
	Parallel.SetWorkerCount(Parallel.CPUCount)
	Parallel.BindEvent("UpdateProgress", _Screen.oMyHandler, "DisplayProgress")
	Parallel.StartWorkers()

	SCAN
		iFilename=ALLTRIM(Fullpath)
		oFilename=ALLTRIM(Newpath)
		RCNON=RCNO
		*Parallel.do("PS2PDF",'convert.prg',,iFilename,oFilename)
		Parallel.CallMethod("ps2pdf", This.Class, This.ClassLibrary,,,iFilename,oFilename,RCNON)
	ENDSCAN

	Parallel.Wait(.T.)
	Parallel.StopWorkers()
ENDPROC
>I have incorporated Parallel Fox in my VFP Code. Using a Single core in my I7 Machine I am able to process 2000 Records in 123 Seconds. Using parallel fox and using all cores of my CPU (i.e 8) I can do the same job with 96 Seconds.
>
>Seems not very great performance using 7 more Cores. Any body having idea, please throw light on the issue.
>
>Here is my code.
>
>
>nRECCOUNTCONVERT=ALLTRIM(STR(RECCOUNT()))
>cRECCOUNTCONVERT=' of '+ALLTRIM(STR(RECCOUNT()))
>
>T1=TIME()
>Local loMyObject
>loMyObject = CreateObject("MyObject")
>_Screen.AddObject("oMyHandler", "MyHandler")
>loMyObject.Mainprocess()
>T2=TIME()
>WAIT WINDOW T2-T1
>Return
>
>Define Class MyHandler as Custom
>Procedure DisplayProgress
>Lparameters lnPercent, lcMessage
>_VFP.StatusBar =  " ("  + "%)"
>EndProc 
>EndDefine 
>
>DEFINE CLASS MyObject AS Custom
>PROCEDURE Mainprocess
>Local Parallel as Parallel
>Parallel = NewObject("Parallel", "ParallelFox.vcx")
>Parallel.StartWorkers()
>SCAN
>iFilename=ALLTRIM(Fullpath)
>oFilename=ALLTRIM(Newpath)
>RCNON=RCNO
>Parallel.SetWorkerCount(Parallel.CPUCount)
>Parallel.BindEvent("UpdateProgress", _Screen.oMyHandler, "DisplayProgress")
>*Parallel.do("PS2PDF",'convert.prg',,iFilename,oFilename)
>Parallel.CallMethod("ps2pdf", This.Class, This.ClassLibrary,,,iFilename,oFilename,RCNON)
>ENDSCAN
>Parallel.Wait(.T.)
>Parallel.StopWorkers()
>ENDPROC
>** Convert ps files to PDF Using ps2PDF.Dll
>PROCEDURE ps2PDF
>PARAMETERS iFilename,oFilename,RCNON
>DECLARE INTEGER _apCreate@0   IN ps2pdf.dll AS apCreate
>DECLARE         _apClose@4    IN ps2pdf.dll AS apClose   INTEGER id
>DECLARE INTEGER _apConvert@4  IN ps2pdf.dll AS apConvert INTEGER id
>DECLARE INTEGER _apSetFunc@24 IN ps2pdf.dll AS apSetFunc INTEGER id, INTEGER code, INTEGER nOptVal1, INTEGER nOptVal2, STRING pOptVal1, STRING pOptVal2
>DECLARE INTEGER _apGetFunc@24 IN ps2pdf.dll AS apGetFunc INTEGER id, INTEGER code, INTEGER nOptVal1, INTEGER nOptVal2, STRING pOptVal1, STRING pOptVal2
>#define AP_Set_Output     3000
>#define AP_Set_Input      3001
>id=apCreate()
>IF (id # 0)
>apSetFunc(id, AP_Set_Input , 0, 0,iFilename, 0)  &&input file.
>apSetFunc(id, AP_Set_Output, 0, 0,oFilename, 0) &&output format and file.
>apConvert(id)
>apClose(id)
>Sys(2335, 1)	&& disable unattended mode, allow UI
>WAIT WINDOW RCNON NOWAIT
>*Worker.UpdateProgress(RECNO(), "Converting..")
>ENDIF
>ENDPROC
>ENDDEFINE
>
>
>
>
>
>
"The five senses obstruct or deform the apprehension of reality."
Jorge L. Borges?

"Premature optimization is the root of all evil in programming."
Donald Knuth, repeating C. A. R. Hoare

"To die for a religion is easier than to live it absolutely"
Jorge L. Borges
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform