New Posts  All Forums:Forum Nav:

Multithreading with VBS

post #1 of 10
Thread Starter 
I am working on a VERY ineficent method to calculate pi, it uses this equation.

((-1 * ((-1) ^ i))/((2 * i) - 1))*4

I was able to thread the equation down into individual components to improve run time a bit/ just for fun, but i am having issues with the main scrip entering variables into the subscripts (threads). How can i have one vbsscript start another then set variables within that subscript?
post #2 of 10
Quote:
Originally Posted by zdude View Post

I am working on a VERY ineficent method to calculate pi, it uses this equation.

((-1 * ((-1) ^ i))/((2 * i) - 1))*4

I was able to thread the equation down into individual components to improve run time a bit/ just for fun, but i am having issues with the main scrip entering variables into the subscripts (threads). How can i have one vbsscript start another then set variables within that subscript?
This isn't what you're going to want to hear, but don't even bother down this route.

VBScript is not only the worst language to be coding in if you want any kind of efficiency, but it's the worst language to be coding in if you want any kind of parallel processing.

My recommendation for you is to learn either Python or Go (sometimes referred to as Golang). Go very easy to pick up and has multiprocessing at it's heart (it makes this kind of problem very easy to solve). Python is more widely used, while again still being easy to learn.

Most people on here will tell you to learn Python (and to be fair to them, that wouldn't be a bad suggestion), but you may find Go a more rewarding language if you're interested in this kind of programming. So have a look into the pair of them and decide which direction you want to start moving into smile.gif
Edited by Plan9 - 3/8/13 at 9:48am
post #3 of 10
Agreed VB is terribly inefficient and clunky. Python is easy to learn and use and c# can be good too
ShadowForge
(12 items)
 
Defiant
(14 items)
 
CarbonCat
(13 items)
 
CPUMotherboardGraphicsRAM
Phenom II x6 1405T (unlocked Athlon II X4 640T) ASUS M5A99X EVO AM3+ Asus ENGTX470/2DI/1280MD5/V2 16 GB (4x4GB) G.Skill DDR3 1600 CAS9 1.35v 
Hard DriveHard DriveOptical DriveCooling
WD Caviar Blue 250 2.5" Laptop Drive WD Caviar Black 1TB 3.5" Pioneer BDR-203 BluRay Burner Corsair H60 push 
OSOSMonitorPower
Windows 7 Pro x64 Ubuntu 11.10 Samsung 40" 60hz  ANTEC NEO ECO 520W 
CaseMouse
NZXT Gamma Microsoft Bluetooth Notebook Mouse 5000 
CPUMotherboardGraphicsRAM
i7 - 2600k [5.0 1.42v] ASUS P8Z68 Deluxe Sapphire HD6950 2gb Dirt 3 Edition 8GB G.Skill DDR3 2133 CAS11 
Hard DriveOSMonitorKeyboard
60GB G.Skill Sniper + 2x1TB Spinpoint F3 Raid0 Win 7 Pro x64 ASUS VW266H Razer Blackwidow 
PowerCaseMouse
Seasonic X750 Gold Corsair Carbide 500R White G9 
  hide details  
Reply
ShadowForge
(12 items)
 
Defiant
(14 items)
 
CarbonCat
(13 items)
 
CPUMotherboardGraphicsRAM
Phenom II x6 1405T (unlocked Athlon II X4 640T) ASUS M5A99X EVO AM3+ Asus ENGTX470/2DI/1280MD5/V2 16 GB (4x4GB) G.Skill DDR3 1600 CAS9 1.35v 
Hard DriveHard DriveOptical DriveCooling
WD Caviar Blue 250 2.5" Laptop Drive WD Caviar Black 1TB 3.5" Pioneer BDR-203 BluRay Burner Corsair H60 push 
OSOSMonitorPower
Windows 7 Pro x64 Ubuntu 11.10 Samsung 40" 60hz  ANTEC NEO ECO 520W 
CaseMouse
NZXT Gamma Microsoft Bluetooth Notebook Mouse 5000 
CPUMotherboardGraphicsRAM
i7 - 2600k [5.0 1.42v] ASUS P8Z68 Deluxe Sapphire HD6950 2gb Dirt 3 Edition 8GB G.Skill DDR3 2133 CAS11 
Hard DriveOSMonitorKeyboard
60GB G.Skill Sniper + 2x1TB Spinpoint F3 Raid0 Win 7 Pro x64 ASUS VW266H Razer Blackwidow 
PowerCaseMouse
Seasonic X750 Gold Corsair Carbide 500R White G9 
  hide details  
Reply
post #4 of 10
Quote:
Originally Posted by selectstriker2 View Post

Agreed VB is terribly inefficient and clunky. Python is easy to learn and use and c# can be good too
VB isn't so bad. VBScript, however, is just terrible in every way imaginable.
post #5 of 10
Thread Starter 
Quote:
Originally Posted by Plan9 View Post

Quote:
Originally Posted by selectstriker2 View Post

Agreed VB is terribly inefficient and clunky. Python is easy to learn and use and c# can be good too
VB isn't so bad. VBScript, however, is just terrible in every way imaginable.

This is meant to be a sort of a stress test, similar to P95, so i am not overly concerned with efficiency, if i ever decide to go for efficiency i will re code it into C but VBS is just easier for me IDK why, now my only question is this why does

Dim objShell
Set objShell = Wscript.CreateObject("WScript.Shell")
objShell.Run "test.vbs"

work when run on its own but when the lines of code are placed into a larger script fail to do anything at all?
post #6 of 10
Personally I think you're using the wrong tool for the job. VBScript is meant for scripting - making lengthy manual tasks easier. If you like Visual Basic syntax, you should do this in VB.NET because I'll show you how to get parallel processing very cheaply using the .NET Framework's parallel task library.
Ol' Sandy
(28 items)
 
"Zeus"
(12 items)
 
Elite Preview
(6 items)
 
CPUMotherboardGraphicsRAM
Intel Xeon E3-1230v3 Gigabyte GA-Z97X-UD5H-BK MSI Gaming GTX 980 Kingston 32GB (4x8) 
Hard DriveHard DriveHard DriveHard Drive
Plextor PX-256M5S 256GB Samsung EVO 1TB Hitachi HDS721010CLA332 Hitachi HDS723020BLA642 
Hard DriveHard DriveHard DriveOptical Drive
Hitachi HDS723020BLA642 Hitachi HUA722010CLA330 WDC WD10EARS-00Z5B1 TSSTcorp CDDVDW SH-S223B 
CoolingCoolingOSMonitor
Phanteks PH-TC14PE with TY-140's Lamptron FCv5 (x2) Windows 8 Pro 64-bit Dell U2412M 
MonitorMonitorMonitorKeyboard
Dell U2412M Dell U2212HM Dell U2713HM Topre Realforce 87UB | Ducky DK9087 G2 Pro 
PowerCaseMouseMouse Pad
Corsair AX-750 Corsair Obsidian 650D Logitech G700 XTRAC Ripper XXL 
AudioAudioAudioAudio
Beyerdynamic DT-770 Pro 250ohm Schiit Bifrost DAC Schiit Asgard 2 HiVi Swan M50W 2.1 
CPUMotherboardRAMHard Drive
Intel Xeon E5-2620 Super Micro X9SRL-F-B 128GB 1333MHz LSI 9271-8i 
OSPowerCase
VMware ESXi 5.5 SeaSonic SS-400FL2 Fractal Define R3 
CPUMotherboardGraphicsRAM
Intel Core i5-3437U HP EliteBook Folio 9470m  Intel HD Graphics 4000  16GB DDR3 SDRAM 
Hard DriveOS
256GB SSD Windows 10 Insider Preview 
  hide details  
Reply
Ol' Sandy
(28 items)
 
"Zeus"
(12 items)
 
Elite Preview
(6 items)
 
CPUMotherboardGraphicsRAM
Intel Xeon E3-1230v3 Gigabyte GA-Z97X-UD5H-BK MSI Gaming GTX 980 Kingston 32GB (4x8) 
Hard DriveHard DriveHard DriveHard Drive
Plextor PX-256M5S 256GB Samsung EVO 1TB Hitachi HDS721010CLA332 Hitachi HDS723020BLA642 
Hard DriveHard DriveHard DriveOptical Drive
Hitachi HDS723020BLA642 Hitachi HUA722010CLA330 WDC WD10EARS-00Z5B1 TSSTcorp CDDVDW SH-S223B 
CoolingCoolingOSMonitor
Phanteks PH-TC14PE with TY-140's Lamptron FCv5 (x2) Windows 8 Pro 64-bit Dell U2412M 
MonitorMonitorMonitorKeyboard
Dell U2412M Dell U2212HM Dell U2713HM Topre Realforce 87UB | Ducky DK9087 G2 Pro 
PowerCaseMouseMouse Pad
Corsair AX-750 Corsair Obsidian 650D Logitech G700 XTRAC Ripper XXL 
AudioAudioAudioAudio
Beyerdynamic DT-770 Pro 250ohm Schiit Bifrost DAC Schiit Asgard 2 HiVi Swan M50W 2.1 
CPUMotherboardRAMHard Drive
Intel Xeon E5-2620 Super Micro X9SRL-F-B 128GB 1333MHz LSI 9271-8i 
OSPowerCase
VMware ESXi 5.5 SeaSonic SS-400FL2 Fractal Define R3 
CPUMotherboardGraphicsRAM
Intel Core i5-3437U HP EliteBook Folio 9470m  Intel HD Graphics 4000  16GB DDR3 SDRAM 
Hard DriveOS
256GB SSD Windows 10 Insider Preview 
  hide details  
Reply
post #7 of 10
Quote:
Originally Posted by zdude View Post

This is meant to be a sort of a stress test, similar to P95, so i am not overly concerned with efficiency, if i ever decide to go for efficiency i will re code it into C but VBS is just easier for me IDK why,

It would be an unreliable stress test though.
Quote:
Originally Posted by zdude View Post

now my only question is this why does

Dim objShell
Set objShell = Wscript.CreateObject("WScript.Shell")
objShell.Run "test.vbs"

work when run on its own but when the lines of code are placed into a larger script fail to do anything at all?

It does work in a larger script. You're not placing that code verbatim inside your larger script

Also, that's such a dangerous trick you're trying to pull. I can't see any sane reason to do that unless you were writing a fork bomb.
Quote:
Originally Posted by tompsonn View Post

Personally I think you're using the wrong tool for the job. VBScript is meant for scripting - making lengthy manual tasks easier. If you like Visual Basic syntax, you should do this in VB.NET because I'll show you how to get parallel processing very cheaply using the .NET Framework's parallel task library.

^ that
post #8 of 10
Thread Starter 
i am just writing this to prove that i can do something that the language was not meant to do (teachers said it wasn't possible and i am going to prove them wrong) so essentially it is yes a fork bomb, but a controlled one tongue.gif

I have it to the point that i am simply debugging small things like forgetting to pass along one of the variables to the worker threads, it will work soon within the next two days I think that it will be working.
post #9 of 10
It isn't possible to do multi-threading with VBS. You might be able to do "parallel" (or a bastardized version of it) by spawning separate processes, but its not the same as multi-threading.
Ol' Sandy
(28 items)
 
"Zeus"
(12 items)
 
Elite Preview
(6 items)
 
CPUMotherboardGraphicsRAM
Intel Xeon E3-1230v3 Gigabyte GA-Z97X-UD5H-BK MSI Gaming GTX 980 Kingston 32GB (4x8) 
Hard DriveHard DriveHard DriveHard Drive
Plextor PX-256M5S 256GB Samsung EVO 1TB Hitachi HDS721010CLA332 Hitachi HDS723020BLA642 
Hard DriveHard DriveHard DriveOptical Drive
Hitachi HDS723020BLA642 Hitachi HUA722010CLA330 WDC WD10EARS-00Z5B1 TSSTcorp CDDVDW SH-S223B 
CoolingCoolingOSMonitor
Phanteks PH-TC14PE with TY-140's Lamptron FCv5 (x2) Windows 8 Pro 64-bit Dell U2412M 
MonitorMonitorMonitorKeyboard
Dell U2412M Dell U2212HM Dell U2713HM Topre Realforce 87UB | Ducky DK9087 G2 Pro 
PowerCaseMouseMouse Pad
Corsair AX-750 Corsair Obsidian 650D Logitech G700 XTRAC Ripper XXL 
AudioAudioAudioAudio
Beyerdynamic DT-770 Pro 250ohm Schiit Bifrost DAC Schiit Asgard 2 HiVi Swan M50W 2.1 
CPUMotherboardRAMHard Drive
Intel Xeon E5-2620 Super Micro X9SRL-F-B 128GB 1333MHz LSI 9271-8i 
OSPowerCase
VMware ESXi 5.5 SeaSonic SS-400FL2 Fractal Define R3 
CPUMotherboardGraphicsRAM
Intel Core i5-3437U HP EliteBook Folio 9470m  Intel HD Graphics 4000  16GB DDR3 SDRAM 
Hard DriveOS
256GB SSD Windows 10 Insider Preview 
  hide details  
Reply
Ol' Sandy
(28 items)
 
"Zeus"
(12 items)
 
Elite Preview
(6 items)
 
CPUMotherboardGraphicsRAM
Intel Xeon E3-1230v3 Gigabyte GA-Z97X-UD5H-BK MSI Gaming GTX 980 Kingston 32GB (4x8) 
Hard DriveHard DriveHard DriveHard Drive
Plextor PX-256M5S 256GB Samsung EVO 1TB Hitachi HDS721010CLA332 Hitachi HDS723020BLA642 
Hard DriveHard DriveHard DriveOptical Drive
Hitachi HDS723020BLA642 Hitachi HUA722010CLA330 WDC WD10EARS-00Z5B1 TSSTcorp CDDVDW SH-S223B 
CoolingCoolingOSMonitor
Phanteks PH-TC14PE with TY-140's Lamptron FCv5 (x2) Windows 8 Pro 64-bit Dell U2412M 
MonitorMonitorMonitorKeyboard
Dell U2412M Dell U2212HM Dell U2713HM Topre Realforce 87UB | Ducky DK9087 G2 Pro 
PowerCaseMouseMouse Pad
Corsair AX-750 Corsair Obsidian 650D Logitech G700 XTRAC Ripper XXL 
AudioAudioAudioAudio
Beyerdynamic DT-770 Pro 250ohm Schiit Bifrost DAC Schiit Asgard 2 HiVi Swan M50W 2.1 
CPUMotherboardRAMHard Drive
Intel Xeon E5-2620 Super Micro X9SRL-F-B 128GB 1333MHz LSI 9271-8i 
OSPowerCase
VMware ESXi 5.5 SeaSonic SS-400FL2 Fractal Define R3 
CPUMotherboardGraphicsRAM
Intel Core i5-3437U HP EliteBook Folio 9470m  Intel HD Graphics 4000  16GB DDR3 SDRAM 
Hard DriveOS
256GB SSD Windows 10 Insider Preview 
  hide details  
Reply
post #10 of 10
Quote:
Originally Posted by zdude View Post

i am just writing this to prove that i can do something that the language was not meant to do (teachers said it wasn't possible and i am going to prove them wrong) so essentially it is yes a fork bomb, but a controlled one tongue.gif

I have it to the point that i am simply debugging small things like forgetting to pass along one of the variables to the worker threads, it will work soon within the next two days I think that it will be working.

If you put this much energy into learning a proper language (even if that language was just another scripting one like Perl or Python), then you might actually produce something useful. tongue.gif
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Application Programming