• Welcome to TechPowerUp Forums, Guest! Please check out our forum guidelines for info related to our community.

Simple WCG PPD Estimator

Also, auto cpu speed detection will be done when I feel like it.
FYI, I spent days trying to figure out the actual clockspeed on my processor using the .NET framework and it wasn't going to happen. I concluded that, in order to obtain the clockspeed, I would have to buy the source from CPUID in order to pull the correct memory addresses and perform the necessary calculations to get the correct values.

The best I could come up with is grabbing it from the registry:
HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\CentralProcessor

However, on my processor, it reports 1.6 GHz or 2.66 GHz when it should be 2.79 GHz.



Suggestion: Why not make the CPU do mock work that BOINC does, crunch a few numbers, then estimate it over x number of hours at y % CPU usage? That way, it would be processor indepenedant. You should have enough information to create a forumla that gets close.

As far as I know, a bunch of double precision multiply and divide should suffice for simulating work.
 
FYI, I spent days trying to figure out the actual clockspeed on my processor using the .NET framework and it wasn't going to happen. I concluded that, in order to obtain the clockspeed, I would have to buy the source from CPUID in order to pull the correct memory addresses and perform the necessary calculations to get the correct values.

The best I could come up with is grabbing it from the registry:
HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\CentralProcessor

However, on my processor, it reports 1.6 GHz or 2.66 GHz when it should be 2.79 GHz.



Suggestion: Why not make the CPU do mock work that BOINC does, crunch a few numbers, then estimate it over x number of hours at y % CPU usage? That way, it would be processor indepenedant. You should have enough information to create a forumla that gets close.

As far as I know, a bunch of double precision multiply and divide should suffice for simulating work.

Yeah I tried grabbing it from the registry but it is sadly not even close. Says my laptop is at 700MHz so I was kinda confused. The user entering it in manually might be the best choice still.
 
Yeah I tried grabbing it from the registry but it is sadly not even close. Says my laptop is at 700MHz so I was kinda confused. The user entering it in manually might be the best choice still.

Well, if it gives bogus values like that, having the user enter it manually probably makes the most sense: if the program gives values that aren't even close to the real values, then it's not very useful
 
i think user input is better,
user can input different speed and get an idea if overclocking is worth it or not
 
Last edited:
Ok ends up that my error checking was severely flawed, and nobody ever caught it because nobody put in 9000 MHz as their CPU frequency. So, to fix this for now, I will take out error checking until I get my homework done. When I am finished I will find a good solution to the problem.

Edit: Expect a new version at 6pm.
 

Attachments

A suggestion on that too:

If the input is invalid, set the usercontrol's BackColor to Pink. If the input is valid, set it to White. Do this in the TextChanged event. For example:
Code:
Private Sub txtClockSpeed_TextChanged(ByVal sender As Object, ByVal e As EventArgs) Handles txtClockSpeed.TextChanged
  Try
    Convert.ToUInt16(txtClockSpeed.Text)
    txtClockSpeed.BackColor = Color.White
  Catch
    txtClockSpeed.BackColor = Color.Pink
  End Try
End Sub

Prior to actually using the data (your calculate button), make sure all nececessary BackColors are not Pink.
 
A suggestion on that too:

If the input is invalid, set the usercontrol's BackColor to Pink. If the input is valid, set it to White. Do this in the TextChanged event. For example:
Code:
Private Sub txtClockSpeed_TextChanged(ByVal sender As Object, ByVal e As EventArgs) Handles txtClockSpeed.TextChanged
  Try
    Convert.ToUInt16(txtClockSpeed.Text)
    txtClockSpeed.BackColor = Color.White
  Catch
    txtClockSpeed.BackColor = Color.Pink
  End Try
End Sub

Prior to actually using the data (your calculate button), make sure all nececessary BackColors are not Pink.

I will try adding this in later. I have tried to do this:

Code:
Private Sub Text1_Keypress(KeyAscii As Integer)
Dim str As String

str=".0123456789"
If KeyAscii>26 then
   If Instr(str,chr(KeyAscii))=0 Then
       KeyAscii=0
   End if
End If
End Sub

But it would simply not work.
 
Yeah, Try...Catch is much better. It will throw an exception, and subsequently catch it, if the conversion failed. ;)
 
It said i would producting
Capture062.jpg

Thats what it estimated for my WCG

Nice little program :)
 
Three more suggestions:
1) Autocheck BOINC version according to CPU architecture. This can be done via:
Code:
System.Environment.GetEnvironmentVariable("PROCESSOR_ARCHITECTURE")
If the result is equal to "x86", it is a 32-bit OS. If the result is equal to "AMD64", it is a 64-bit OS.

Taking it a step further, find boinc.exe or wcg.exe (not sure on that one) and detect if it is running 32-bit or not. I'm not certain this is possible though...


2) Auto-clear Speed and Usage when someone clicks in it. If Text = "MHz", Text = "" on text change, for example.

3) Maybe accept GHz or MHz. If there is no decimal point, assume MHz. If there is a decimal point, assume GHz. I can type up some code for that too if you want it.
 
I was going to have it find boinc.exe or wcg.exe but I realized some people install them in different places.

I did not put in auto checking for a 32 bit or 64 bit cpu cause some people run 32 bit boinc instead of 64 on their 64 bit system.

And for the ghz or mhz thing, I think I will stick to mhz only.

Edit: Regarding processor architecture, I realized that the mobile versions on the C2D were thought of the same as the desktop time.
 
Also, here is the latest version.

EDIT: FordGT90Concept, you are in the credits.
 

Attachments

i was wandering if you could put in how long it would take to get the number it says like a i7 at 100% is around 22k but how long does it take to do that like in a hour, 22hours
. you know
 
It was a lot of work but I finally cracked it:
Code:
    Private Declare Function IsWow64Process Lib "kernel32" (ByVal hProcess As IntPtr, ByRef Wow64Process As Boolean) As Int32
    Public Function IsRunningApp64Bit(ByVal name As String) As Boolean
        If Environment.GetEnvironmentVariable("PROCESSOR_ARCHITECTURE") = "AMD64" Then
            Dim processes As Process() = Process.GetProcessesByName(name)
            If processes.Length > 0 Then
                Dim wow64 As Boolean
                Try
                    Dim ret As Int32 = IsWow64Process(processes(0).Handle, wow64)
                    If ret > 0 Then
                        If wow64 = False Then
                            Return True ' Not emulated (32-bit on 32-bit or 64-bit on 64-bit).
                        Else
                            Return False ' Emulated (32-bit on 64-bit).
                        End If
                    Else
                        Return False ' There was a problem.
                    End If
                Catch
                    Return False ' Problem with getting process info.
                End Try
            Else
                Return False ' Process not found.
            End If
        Else
            Return False ' 32-bit OS.
        End If
    End Function
Run it for "boinc" and also "wcg" (I think). If it returns true for either one of them, check 64-bit. If it does not, check 32-bit.


Edit: Required imports:
Code:
Imports System


Edit: I only have BOINC (64-bit) installed here so I don't know what the process name for WCG would be. Just make sure to drop the ".exe" and it should work.
 
Last edited:
i was wandering if you could put in how long it would take to get the number it says like a i7 at 100% is around 22k but how long does it take to do that like in a hour, 22hours
. you know

I understand but an unsure if I want to add it in. The program is after all PPD Estimator, the units being in days!
 
It was a lot of work but I finally cracked it:
Code:
    Private Declare Function IsWow64Process Lib "kernel32" (ByVal hProcess As IntPtr, ByRef Wow64Process As Boolean) As Int32
    Public Function IsRunningApp64Bit(ByVal name As String) As Boolean
        If Environment.GetEnvironmentVariable("PROCESSOR_ARCHITECTURE") = "AMD64" Then
            Dim processes As Process() = Process.GetProcessesByName(name)
            If processes.Length > 0 Then
                Dim wow64 As Boolean
                Try
                    Dim ret As Int32 = IsWow64Process(processes(0).Handle, wow64)
                    If ret > 0 Then
                        If wow64 = False Then
                            Return True ' Not emulated (32-bit on 32-bit or 64-bit on 64-bit).
                        Else
                            Return False ' Emulated (32-bit on 64-bit).
                        End If
                    Else
                        Return False ' There was a problem.
                    End If
                Catch
                    Return False ' Problem with getting process info.
                End Try
            Else
                Return False ' Process not found.
            End If
        Else
            Return False ' 32-bit OS.
        End If
    End Function
Run it for "boinc" and also "wcg" (I think). If it returns true for either one of them, check 64-bit. If it does not, check 32-bit.


Edit: Required imports:
Code:
Imports System


Edit: I only have BOINC (64-bit) installed here so I don't know what the process name for WCG would be. Just make sure to drop the ".exe" and it should work.

Ok I have decided to do this:

Maybe one person has this calculator on 1 PC, and then they want to calculate their other PC's and not have to put this program on their computers, then this should work.

NOW: I like the program F@HMon. Ever used it? It calculates the time a WU will take to complete, PPD, etc. If we start making this all automated, I will make a program like F@HMon for WCG, HOWEVER: Is there a program like this already? If not, I will start to automate all parts of the calculator and start work on WCGMon.
 
F@H just calculates F=ma over and over and over again. The workload doesn't change so it is easy to estimate how long each individual WU will take given how many calculations there are to perform. WCG/BOINC, on the other hand, handle a multitude of different kinds of tasks so it isn't easy to accurately estimate how long any given task will take to complete. Not to mention, WCG/BOINC already do this (see Tasks tab).



By the way, I'd use that code to select the default BOINC type (32-bit or 64-bit). The user can easily check the other option if it isn't for their computer.


Edit: Another suggestion:

I assume the code to calculate the points isn't very intensive. As such, you could easily remove the Calculate button and make TextChanged, SelectedIndexChanged, and CheckedChanged all point to the Calculate code. That way, if everything is valid, it will calculate it as the information becomes available.
 
Last edited:
Edit: Another suggestion:

I assume the code to calculate the points isn't very intensive. As such, you could easily remove the Calculate button and make TextChanged, SelectedIndexChanged, and CheckedChanged all point to the Calculate code. That way, if everything is valid, it will calculate it as the information becomes available.

Excellent idea, however, this might be problematic once your previous idea is implemented.
 
The 32-bit/64-bit code? That should occur only once on startup (in the Form constructor).
 
Ok as promised:

0.1.2: Many fixes. Please put in original post [Ion].

EDIT: Also, FordGT90Concept, the button looks so pretty don't make me remove it! (I am changing code as we speak)
EDIT2: O wow errors are flipping out, computer crashed... need to fix my error reporting badly!
 

Attachments

Worked fine for me.
Neat work!
 
Worked fine for me.
Neat work!

Now I want some screenshots if you don't mind. Try putting putting non-integers into the field, etc.

EDIT: Look at what we did over a weekend guys!

Screenshot is of all the versions of the program!

Capture046.jpg


Now, does anyone have an idea for a better UI?
 
Last edited:
I'm not sure if you were asking for something like this?

wcg1.jpg
 
Last edited:
Back
Top