Profile results (total time)
Proc Name Self CPU Total CPU Real Time Calls
--------------------------- --------- --------- --------- ---------
/mob/verb/Subtract_Test1 0.000 0.450 0.450 1
/pif_BigInt/proc/Subtract 0.153 0.450 0.450 30
/pif_BigInt/proc/Set 0.074 0.169 0.169 30
/pif_BigInt/New 0.000 0.169 0.169 30
/pif_BigInt/proc/_GetBlock 0.100 0.117 0.124 90030
/pif_BigInt/proc/_SetBlock 0.087 0.107 0.113 60090
/pif_BigInt/proc/Length 0.036 0.038 0.060 150285
/pif_BigInt/proc/LargestBit 0.000 0.000 0.000 30
/pif_BigInt/proc/Expand 0.000 0.000 0.000 45
/pif_BigInt/proc/Contract 0.000 0.000 0.000 36
/pif_BigInt/proc/Sign 0.000 0.000 0.000 60
And the difference of two randomly-generated, 24,000 hexadecimal digit (~29,000 decimal digit) integers.
Profile results (total time)
Proc Name Self CPU Total CPU Real Time Calls
--------------------------- --------- --------- --------- ---------
/mob/verb/Subtract_Test2 0.000 0.095 0.095 1
/pif_BigInt/proc/Subtract 0.037 0.095 0.095 1
/pif_BigInt/proc/Set 0.019 0.037 0.037 1
/pif_BigInt/New 0.000 0.037 0.037 1
/pif_BigInt/proc/_GetBlock 0.017 0.022 0.026 18001
/pif_BigInt/proc/_SetBlock 0.014 0.018 0.020 12004
/pif_BigInt/proc/Length 0.008 0.008 0.011 30011
/pif_BigInt/proc/LargestBit 0.000 0.000 0.000 1
/pif_BigInt/proc/Expand 0.000 0.000 0.000 2
/pif_BigInt/proc/Contract 0.000 0.000 0.000 2
/pif_BigInt/proc/Sign 0.000 0.000 0.000 2
I was surprised to see that subtraction was about 21% faster than addition, considering they use almost exactly the same algorithm with only a few minor modifications. I re-ran the addition test with some different sets of numbers, to make sure I wasn't accidentally getting 'nice' values somehow, and I'm seeing speeds similar to the subtraction test now.
Profile results (total time)
Proc Name Self CPU Total CPU Real Time Calls
--------------------------- --------- --------- --------- ---------
/mob/verb/Add_Test2 0.000 0.090 0.090 1
/pif_BigInt/proc/Add 0.034 0.090 0.090 1
/pif_BigInt/proc/Set 0.014 0.033 0.033 1
/pif_BigInt/New 0.000 0.033 0.033 1
/pif_BigInt/proc/_SetBlock 0.023 0.027 0.025 12002
/pif_BigInt/proc/_GetBlock 0.010 0.016 0.025 18001
/pif_BigInt/proc/Length 0.009 0.009 0.011 30008
/pif_BigInt/proc/LargestBit 0.000 0.000 0.000 1
/pif_BigInt/proc/Expand 0.000 0.000 0.000 1
/pif_BigInt/proc/Sign 0.000 0.000 0.000 2
I had made a few changes to the addition algorithm, as I found a couple things that were not needed, but none that I thought would speed it up that significantly. Kinda surprising.
[Edit]
Realized I undercounted the number of digits.
Wacky Waving Inflatable Arm Flailing Tube Man!