I use visual basic 2008 for a console application. In a nut shell, my script does a lot of calculation and writes the results to text files. It reads from files and appends to them. The only problem is that 60% of the clock speed goes towards keeping up with windows 7 and that is just such a waste. Therefore i ask you if there is a way of running the script before windows starts up or something. And if there is, could someone guide me through the exact process of doing so, because my programming skills are probably close to none ;/ and also if it is possible, how would i go about stopping it and resuming the start up of the OS, because the script could potentially go on forever, i have no idea how would i make it stop, as it does not ask for any input from the user, it does everything automatically. I could paste in the full code, but not today as the script is on my laptop and I'm on my computer, but if it is required for me to get help I can paste it in here tomorrow. Thanks for help in advance :)
If the description is messy, it's because I'm crap at getting my ideas across, sorry :p
3 replies to this topic
#1
Posted 28 March 2011 - 02:39 PM
|
|
|
#2
Posted 28 March 2011 - 02:57 PM
Visual BASIC (and .NET proponent) requires both the .NET and VB runtimes to load any scripts, and the .NET runtimes may rely on any number of other libraries so that you basically have loaded the operating system by the time you could run it.
I do not understand what you mean about clock speed wasted, as long as no programs running in task manager you should see at least 90% of the CPU time allocated to system idle process (which is otherwise free), and should provide sufficient computing power for your calculations.
You can however, set the priority of your application or its threads to high or real time (preferably the former) to give it exclusive CPU access. I believe this requires the System.Diagnostics namespace and can be done in just a few lines.
I do not understand what you mean about clock speed wasted, as long as no programs running in task manager you should see at least 90% of the CPU time allocated to system idle process (which is otherwise free), and should provide sufficient computing power for your calculations.
You can however, set the priority of your application or its threads to high or real time (preferably the former) to give it exclusive CPU access. I believe this requires the System.Diagnostics namespace and can be done in just a few lines.
Be sure to read the updated FAQ! || Health is achieved through the same 10,000 steps.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.
#3
Posted 03 April 2011 - 10:19 AM
szef_mtp said:
The only problem is that 60% of the clock speed goes towards keeping up with windows 7 and that is just such a waste.
- Check your computer for malware (virii, worms, trojan, etc).
- You seriously need to upgrade your hardware.
Quote
Therefore i ask you if there is a way of running the script before windows starts up or something.
If what you are after is to get your program/script to get more CPU time, then you could either try Alex' advice to increase the priority of your process (with WinAPI it's actually only one line of code), or make your program/script as the shell (replacing explorer.exe).
#4
Posted 03 April 2011 - 12:09 PM
Quote
If this is accurate, then you may want to either
- Check your computer for malware (virii, worms, trojan, etc).
- You seriously need to upgrade your hardware.
Quote
If what you are after is to get your program/script to get more CPU time, then you could either try Alex' advice to increase the priority of your process (with WinAPI it's actually only one line of code), or make your program/script as the shell (replacing explorer.exe).
Yes, I'd like to maximize the cpu time my script is getting, but I've no idea how to do it. I'd just be happy for someone to explain how to do it as my knowledge of computers is infinetisimal ;/ here's the source code:
Quote
Sub Main()
Dim number As UInteger, y As UInteger, flag, flag2 As Boolean
loadnumber(number)
currentfileno = 1
Do
flag = True
flag2 = True
linecount = 0
Dim objReader As New System.IO.StreamReader(FILE_NAME & currentfileno & ".txt")
Do While objReader.Peek() <> -1 And flag = True And flag2 = True
y = objReader.ReadLine()
If number < y * y Then
flag2 = False
ElseIf number Mod y = 0 Then
flag = False
End If
linecount += 1
Loop
objReader.Close()
If linecount = 1000000 Then
currentfileno += 1
Else
If flag = True Then
addingtofile(number)
'Console.WriteLine(number)
End If
currentfileno = 1
number += 2
End If
Loop
End Sub
Dim number As UInteger, y As UInteger, flag, flag2 As Boolean
loadnumber(number)
currentfileno = 1
Do
flag = True
flag2 = True
linecount = 0
Dim objReader As New System.IO.StreamReader(FILE_NAME & currentfileno & ".txt")
Do While objReader.Peek() <> -1 And flag = True And flag2 = True
y = objReader.ReadLine()
If number < y * y Then
flag2 = False
ElseIf number Mod y = 0 Then
flag = False
End If
linecount += 1
Loop
objReader.Close()
If linecount = 1000000 Then
currentfileno += 1
Else
If flag = True Then
addingtofile(number)
'Console.WriteLine(number)
End If
currentfileno = 1
number += 2
End If
Loop
End Sub
+ some user defined functions
I'm especially interested how would i go about replacing it for explorer.exe? and also how to put explorer.exe back in, because if I understand well, then putting that script as a shell will decrease performance of the laptop drastically if I wanted to do anything else.
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users


Sign In
Create Account

Back to top









