Click here to Skip to main content
15,909,539 members
Home / Discussions / Visual Basic
   

Visual Basic

 
QuestionMultithreading slower? [modified] Pin
NikWing6-May-10 5:36
NikWing6-May-10 5:36 
AnswerRe: Multithreading slower? Pin
Luc Pattyn6-May-10 5:52
sitebuilderLuc Pattyn6-May-10 5:52 
GeneralRe: Multithreading slower? Pin
NikWing6-May-10 6:33
NikWing6-May-10 6:33 
GeneralRe: Multithreading slower? Pin
Luc Pattyn6-May-10 7:00
sitebuilderLuc Pattyn6-May-10 7:00 
GeneralRe: Multithreading slower? Pin
NikWing6-May-10 7:45
NikWing6-May-10 7:45 
GeneralRe: Multithreading slower? Pin
Luc Pattyn6-May-10 8:34
sitebuilderLuc Pattyn6-May-10 8:34 
GeneralRe: Multithreading slower? Pin
Luc Pattyn6-May-10 12:38
sitebuilderLuc Pattyn6-May-10 12:38 
GeneralRe: Multithreading slower? [modified] Pin
NikWing6-May-10 13:23
NikWing6-May-10 13:23 
Thanks for your time, Luc Smile | :)

no no, I just didn't paste the code you're missing Smile | :)
the program is about 4200 lines right now so I kinda forgot to paste this:
Public Module Variables_form1
    Friend result As String = ""
End Module


so I set result to nothing, call the hashfile function with the full filename, it returns the hash and stores it in a new datatable row

like I said, the original program runs without a flaw, just the double-thread stuff breaks it somehow ...

I gave up for today 10 mins ago.
the timer instead of invoke didn't speed it up.
the progressbar value is between 96% and 100%, usually 99%.
progbar.Maximum value is aryFi_hashdups.count, current value is the sum of each FOR .. NEXT counter, ((r1) + (r2 - aryficnt_b + 1)) where aryficnt_b = Math.Ceiling(aryFi_hashdups.Count / 2)

But beside this, the tables are broken somehow
I thought the problem occurs when I copy each table row by row to a new table
but both have the correct amount of lines, as in, I hashed 838 files, each table contains 419 rows
I skipped making a new table out of table_a and table_b and altered the compare part to use table_a, then table_b.
the problem still occurs, the number of results varies. I tried it with my single thread version, the result won't vary and it's correct.

I now try to find out if the aryFi_hashdups array varies. I can't imagine this, why should it alter itself while the program runs? it's just a list of filenames as far as I know (di.getfiles(*.*), and after it's created nothing changes it ...)

I divide it's count by 2, round one to floor, one to ceiling and have 2 loops

Dim aryficnt_a As Integer = Math.Floor(aryFi_hashdups.Count / 2)
For r1 = 0 To aryficnt_a - 1
Next


and

Dim aryficnt_b As Integer = Math.Ceiling(aryFi_hashdups.Count / 2)
For r2 = aryficnt_b To aryFi_hashdups.Count - 1
Next


I just don't understand, I don't see anything that interferes ...

edit: uh, just thought of something ... could the problem be that I only have one hash function and also just one "result" ?
I'll copy the hash function and change result to result_a and result_b and see if that works ...
I will try that now, though it's already 1:25 am ^^

edit2: I guess that was the problem of the wrong results. now the result won't vary anymore. I also fixed the progressbar value, I have to make more tests with different files, but for now it finishes with 100%

with taskman I monitored the cpu usage. without visible caching (1st run) it uses between 2 and 5% of CPU, no idea why it doesn't use more. the hdd isn't very active, only flashing now and then.
WITH visible caching (2nd run etc) it uses 50% of the CPU and of course is much faster.

I have to compare both versions of the code again, how much time each takes for 1000 files and if anything improved ...

modified on Thursday, May 6, 2010 7:32 PM

General!!!DO NOT DUPLICATE CODE!!! Pin
Luc Pattyn6-May-10 13:37
sitebuilderLuc Pattyn6-May-10 13:37 
GeneralRe: !!!DO NOT DUPLICATE CODE!!! Pin
NikWing6-May-10 14:03
NikWing6-May-10 14:03 
GeneralRe: !!!DO NOT DUPLICATE CODE!!! Pin
Luc Pattyn6-May-10 14:12
sitebuilderLuc Pattyn6-May-10 14:12 
GeneralRe: !!!DO NOT DUPLICATE CODE!!! Pin
NikWing6-May-10 14:57
NikWing6-May-10 14:57 
GeneralRe: !!!DO NOT DUPLICATE CODE!!! Pin
Dave Kreskowiak6-May-10 16:57
mveDave Kreskowiak6-May-10 16:57 
GeneralRe: !!!DO NOT DUPLICATE CODE!!! Pin
NikWing7-May-10 0:43
NikWing7-May-10 0:43 
GeneralRe: Multithreading slower? Pin
Luc Pattyn6-May-10 13:57
sitebuilderLuc Pattyn6-May-10 13:57 
GeneralRe: Multithreading slower? Pin
NikWing6-May-10 14:21
NikWing6-May-10 14:21 
AnswerRe: Multithreading slower? Pin
Luc Pattyn6-May-10 6:14
sitebuilderLuc Pattyn6-May-10 6:14 
AnswerRe: Multithreading slower? Pin
supercat96-May-10 6:54
supercat96-May-10 6:54 
GeneralRe: Multithreading slower? Pin
NikWing6-May-10 7:56
NikWing6-May-10 7:56 
GeneralRe: Multithreading slower? Pin
supercat96-May-10 9:11
supercat96-May-10 9:11 
GeneralRe: Multithreading slower? Pin
NikWing7-May-10 0:50
NikWing7-May-10 0:50 
QuestionMaximum number in an array? Pin
Adam Wike6-May-10 4:51
Adam Wike6-May-10 4:51 
AnswerRe: Maximum number in an array? Pin
Luc Pattyn6-May-10 5:04
sitebuilderLuc Pattyn6-May-10 5:04 
AnswerRe: Maximum number in an array? Pin
dan!sh 6-May-10 5:06
professional dan!sh 6-May-10 5:06 
GeneralRe: Maximum number in an array? Pin
Adam Wike6-May-10 7:36
Adam Wike6-May-10 7:36 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.