Search found 83 matches

by fvillanova
Sun Aug 04, 2024 7:48 pm
Forum: Coding Questions
Topic: More speed to know if it is even
Replies: 25
Views: 4930

Re: More speed to know if it is even

I hadn't noticed, with this small change the times
are shorter in the routines modified by me.

Code: Select all

k=0: n=0 
!MOV   r13, qword [v_total_results ]

Removing the instruction: "j=total_results"
by fvillanova
Sun Aug 04, 2024 7:31 pm
Forum: Coding Questions
Topic: More speed to know if it is even
Replies: 25
Views: 4930

Re: More speed to know if it is even


Results on windows 11 64
PureBasic 5.73 x64 (for many compatibility reasons) I can't change it, I've already explained this in another topic, this
is the fastest and most efficient version for my systems:
*mat\ 100 ms n=4
answers() 104 ms n=4
Demivec solution 111 ms n=4
Demivec modified 81 ms n=4 ...
by fvillanova
Sun Aug 04, 2024 6:32 pm
Forum: Coding Questions
Topic: More speed to know if it is even
Replies: 25
Views: 4930

Re: More speed to know if it is even


The secret to option three is simplification. I record the longest series of even numbers by looking only at one number at a time. I then eliminate the case of only one number in a sequence (results of a sequence count are in the set {n = 0; n > 1}. I just happen to look at the series in reverse ...
by fvillanova
Sun Aug 04, 2024 2:55 am
Forum: Coding Questions
Topic: More speed to know if it is even
Replies: 25
Views: 4930

Re: More speed to know if it is even

Here is the segment of my program that needs to quickly know if two numbers are "even":
DisableDebugger
Structure FiltroElement
N.i
N1.i
EndStructure
Procedure Split(String.s, Array new.i(1), Separator.s = ",")
Protected S.String, *S.Integer = @S
Protected.i asize, i, p
asize = CountString ...
by fvillanova
Sat Aug 03, 2024 7:32 pm
Forum: Coding Questions
Topic: More speed to know if it is even
Replies: 25
Views: 4930

Re: More speed to know if it is even


But I am looking for an even faster technique because I need to put this inside a subroutine that is processed tens of billions of times in a simulation system that I made and that is processing correctly, I just want to speed up the process.


I doubt if you will find anything faster as n & 1 ...
by fvillanova
Sat Aug 03, 2024 3:48 pm
Forum: Coding Questions
Topic: More speed to know if it is even
Replies: 25
Views: 4930

Re: More speed to know if it is even


1 Odd
0 Even

Debug 5 % 2
Debug 4 % 2


Hi Rashad, using the "n & 1" command the performance is much faster.
But I am looking for an even faster technique because I need to put this inside a subroutine that is processed tens of billions of times in a simulation system that I made and that is ...
by fvillanova
Sat Aug 03, 2024 2:29 am
Forum: Coding Questions
Topic: More speed to know if it is even
Replies: 25
Views: 4930

Re: More speed to know if it is even


For timing of a particular function, you'd be wise to remove the Random() calls, as they can contribute to ~50% of your measured time.

Fred updated the GCC compiler version a few PureBasic releases ago (certainly from 6.10 onwards). I discovered that using this updated C compiler (with the ...
by fvillanova
Sat Aug 03, 2024 2:19 am
Forum: Coding Questions
Topic: More speed to know if it is even
Replies: 25
Views: 4930

Re: More speed to know if it is even



t1 = ElapsedMilliseconds(): RandomSeed(0): e=0
For i=1 To 20000000
n=Random(99,0)+1
EnableASM
MOV EAX, n
TEST EAX, 1
JZ l_labelend
INC e
LabelEnd:
DisableASM
Next
Result$+"n & 1 = "+Str(i-1)+" in "+StrF((ElapsedMilliseconds()-t1),0)+" ms even="+Str(e)+Chr(13)

Not Really faster. (1 -2 ...
by fvillanova
Sat Aug 03, 2024 2:12 am
Forum: Coding Questions
Topic: More speed to know if it is even
Replies: 25
Views: 4930

Re: More speed to know if it is even


It depends that you need it for.
If you need to count the number of evens like in your example, get rid of the if construction.
For i=1 To 20000000
n=Random(99,0)+1: e+(n&1)
Next
This is a lot faster.

In my program I need to ask if the number is even, it can't just be counting the number of ...
by fvillanova
Fri Aug 02, 2024 11:19 am
Forum: Coding Questions
Topic: More speed to know if it is even
Replies: 25
Views: 4930

More speed to know if it is even

Hello everyone, here I am again, asking for help to make a routine as fast as possible.
I just need to know if the number "n" is even or not.
Here on my computer the last option "n & 1" is the fastest, does anyone have an idea to speed it up?
See: DisableDebugger
Define.i i,n,e
; the value of n will ...
by fvillanova
Sun May 12, 2024 2:50 am
Forum: Coding Questions
Topic: Lines of a ListView Gadget to ClipBoard
Replies: 8
Views: 1136

Re: Lines of a ListView Gadget to ClipBoard


Using a "virtual" ListIconGadget instead of the ListViewGadget and a faster string concatenation:
CompilerIf #PB_Compiler_Debugger
CompilerError "Disable the Debugger..."
CompilerEndIf

#LVSICF_NOINVALIDATEALL = 1
#LVSICF_NOSCROLL = 2
#LVN_ODCACHEHINT = #LVN_FIRST - 13

#ItemCount = 10000 ...
by fvillanova
Thu May 02, 2024 12:59 am
Forum: Coding Questions
Topic: Lines of a ListView Gadget to ClipBoard
Replies: 8
Views: 1136

Re: Lines of a ListView Gadget to ClipBoard

WOW! There's nothing like asking someone who understands.
I have many programs that need to take strings from the ListView and pass them to the clipboard, now it will be instantaneous!
Both solutions are fantastic, thanks to Demivec and BarryG .
I have no words to thank you, it will help me a lot ...
by fvillanova
Wed May 01, 2024 10:22 pm
Forum: Coding Questions
Topic: Lines of a ListView Gadget to ClipBoard
Replies: 8
Views: 1136

Lines of a ListView Gadget to ClipBoard

Hello everyone, today I'm asking for help again.
All programs I currently code in PureBasic are extremely fast and compact, but there is still a small and simple routine for copying TXT lines from a "Listview gadget" which is very... but very slow by PureBasic standards.
I'm going to put a small ...
by fvillanova
Mon May 29, 2023 6:47 pm
Forum: Coding Questions
Topic: Comparisons in mathematical simulations
Replies: 62
Views: 7569

Re: Comparisons in mathematical simulations


I think for a unique key there's no need to append the z characters.
Without appending them (just 171 and 4221) the key should still be unique.

Yes, the "z" are not necessary because "0" is in the key when there is no occurrence:
171 is very different from 0171, it will work perfectly ...
by fvillanova
Mon May 29, 2023 4:16 pm
Forum: Coding Questions
Topic: Comparisons in mathematical simulations
Replies: 62
Views: 7569

Re: Comparisons in mathematical simulations


Another question ...
Would it be okay for you to use fixed strings and call the procedure in a different way ?
Define.s{10} a1,a2 instead of Define.s a1,a2
and call by
Today(@String1,@a1,18,1) instead of a1=Today(@String1,18,1)
If that would be no problem to you, it can be made extremely fast ...