summaryrefslogtreecommitdiff
path: root/bench/bigint.myr
diff options
context:
space:
mode:
Diffstat (limited to 'bench/bigint.myr')
-rw-r--r--bench/bigint.myr209
1 files changed, 209 insertions, 0 deletions
diff --git a/bench/bigint.myr b/bench/bigint.myr
new file mode 100644
index 0000000..f1ac0f9
--- /dev/null
+++ b/bench/bigint.myr
@@ -0,0 +1,209 @@
+use std
+use testr
+
+const main = {
+ var a, b
+
+ a = std.get(std.bigparse(astr))
+ b = std.get(std.bigparse(bstr))
+ testr.bench([
+ [.name="bigfactorial-1", .fn={ctx; bigfact(1)}],
+ [.name="bigfactorial-100", .fn={ctx; bigfact(100)}],
+ [.name="bigfactorial-1000", .fn={ctx; bigfact(1000)}],
+ [.name="bigfactorial-10000", .fn={ctx; bigfact(10000)}],
+ [.name="bigmul-bothbig", .fn={ctx; bigmul(a, b)}],
+ ][:])
+}
+
+const bigfact = {n
+ var i
+ var x, y
+
+ if n == 0
+ x = std.mkbigint(1)
+ else
+ x = std.mkbigint(n)
+ for i = n-1; i > 0; i--
+ y = std.mkbigint(i)
+ std.bigmul(x, y)
+ std.bigfree(y)
+ ;;
+ ;;
+ -> x
+}
+
+const bigmul = {a, b
+ var r = std.bigdup(a)
+ std.bigmul(r, b)
+ std.bigfree(r)
+}
+
+const astr = \
+ "786226786586600439317972610307453185844816038396887410361680" \
+ "057562738205768169440311788359575359662484806302309290559269" \
+ "528840503089778892166969404943179665354542662022501031093355" \
+ "271292443882546985002869031472840087285045002214375586489512" \
+ "119373071089907222993450120378930997902435685145827038085819" \
+ "296865519485069915539726113453392326014373721767082018422958" \
+ "717062721702582361925462085790615747641302901942695904395406" \
+ "834224622529709782228408774414640957447279927460707815981786" \
+ "406994864430875491075424852796017575153912350736693997340109" \
+ "179809249816546470560796013608371676540452470243110540567406" \
+ "131454930387632550432649269771702882918734039217249418671214" \
+ "578343865544182288638782234366945485699781398626899358422106" \
+ "382221586857747438786541396870348009298608214885868257313676" \
+ "649092812753573767742580234440720920671581633553397695353934" \
+ "132303144338968914681227568810598784423402415568066389616154" \
+ "614818275979465719251274076724898041828550631986321592027149" \
+ "396140957537591558324156214045032930669195479259917491373556" \
+ "8106323004563791966979449"
+
+const bstr = \
+ "187308423231504228611111080270112029294766282678254231118742" \
+ "976869035200603975231371287575334271604770730635239117286259" \
+ "633494749566591369947211092881454729202366597231676526591300" \
+ "648610814270646993620412724160164594497114189417456618983125" \
+ "754243263403220712648959862959656559260934591165571538609438" \
+ "590305501075673585878506798890948928998460512317734318100422" \
+ "301601872241161203780242712104705885977145795396152336901291" \
+ "797346494631790697490596412053544611041844456774577364325024" \
+ "070127433788225479200261038961006069382091341032772858886595" \
+ "126748124988322385484529859500424755864562815273650872459428" \
+ "604927038475035756775266526245762679156608674463485106692013" \
+ "334198263770435008762560094658051091261225051459463607555576" \
+ "909910323885506799911997243762894976997772525420734032010908" \
+ "232750510323630849750298879815023574738441149575389970852774" \
+ "177147447530826963987253002135706371359716529615192991331710" \
+ "358753881164433191999293286713740248283177543479283727214184" \
+ "724131647548393947909056785714667606883184085430899204162328" \
+ "826158851207379006944693295498006311569980249630659828437857" \
+ "675974052589856026178343278810044863262932813277009490639496" \
+ "536609737088886342712009625141736821206684450062603392153153" \
+ "404209821474892409175922249782691829080890709213170466577080" \
+ "377570831150029278547755147996902849300234357700933105059734" \
+ "535663014087527221170181231192295192940913638374876317838628" \
+ "513685521076746695302116096246663697634145614610623764326966" \
+ "034284535477345974781679205896638416144421212858502427308326" \
+ "932579573129945442468876557939601952816014080189349604230705" \
+ "365868935617410975446640273108649254906769023875954001915851" \
+ "664244700370024600464468562174205614316632651533572360375076" \
+ "397825425411906188567274646160369108041601789830804365153321" \
+ "786129972802577217675779977803595583990850309499110057500386" \
+ "963299465049980241112611167139170503250450996990310096129565" \
+ "074487177158657223017144483992415686889386032110805070566222" \
+ "391021704709176968022469625318920962164345682090022548949639" \
+ "373535013410140815528983041981416489359560548762773247027894" \
+ "433410249929507117822644701257908554656601684665483333856314" \
+ "445354748390977894664864352404291796587312266255127874784721" \
+ "619161441066868319035508018794580703871852715612431050120428" \
+ "135204914805088588056364008960061473425114169699056353553362" \
+ "684434702224467541950013135029769757734688969972162892564754" \
+ "794607854348784493170718776237831436345037722624425771190246" \
+ "018034960769040875816438953729709133678842811906949629452358" \
+ "733021110486943979165015168688484556308945464367476269193790" \
+ "416269749963298838914536589681414703854517183672658308513799" \
+ "079924527379662830333236086766377066200832536550279672992236" \
+ "534386204300849885908109898105830852146495986415657102811369" \
+ "595247130333705192417745868596617533375480391948415664293960" \
+ "986757335528872844228230415255122202991202927184519763895621" \
+ "784166281785570962980369244162505438453718048719964848583896" \
+ "857048160613386597344498469472976896546659619163220731196501" \
+ "323014018615871231780371169751103683603599982508157269363828" \
+ "411288512876302246976722591644117294608452539733909759953439" \
+ "531429839711890887198366410539288744251028511505016177386244" \
+ "749167411006850944434211305749841593738801775687547388254201" \
+ "939297777489971469491544250094576226609276643868397292318619" \
+ "638481092861366771094145813562129333311647611902685299968882" \
+ "120832495897029738418349759779717411822241304202704141876186" \
+ "021609477309152514796122336409731627673520687854759447557901" \
+ "364641037659836873710690927438194862217026533565020830538006" \
+ "474368344215360348610383201842027979922422061958838533809305" \
+ "769494429697360443510783300535985639987094328411985571590736" \
+ "668585260182179277329957988272484981238401320570887133681587" \
+ "104377431152847065007690135501166962851804129900971535475096" \
+ "780466463541055999770138832441321686999264335797733246187289" \
+ "627201885855368556615429895387994196080244415898422345868310" \
+ "490709239989887413180596388426579419833690268988006284505869" \
+ "050445508634068307421234527095591085036542160387367691944010" \
+ "975408030387045757333117117106642362746817079296595077266231" \
+ "539797438547718217585348401525110815431508041372063435381246" \
+ "031899285980848878201413896797811316833560553995491439595681" \
+ "923196663368947274989655741723930512233824969005097885029422" \
+ "357501820683035694227690760029389720555091326855256135152515" \
+ "991629667196092383555620493513052376816166150463402645212712" \
+ "906520400777603115930223645552970514327317217278507643140717" \
+ "182239925721890342870110303375808665304693222547743946076755" \
+ "692015880794045769310816721195424546206360150602831845794754" \
+ "107728490276051145716712025134135902681643628483224712234443" \
+ "063152270612970654343583032461561909892954923011301907408278" \
+ "407275948095435658167567889516277464704601392558782479050096" \
+ "372379916668232181458496952539316561733622359194587739442387" \
+ "588748382930523021381163994808898807073006256512121958841602" \
+ "953834143318421508854501873168004451093624401020578718864158" \
+ "163753449732176772997318191567270326934788485419221293796231" \
+ "298858119919950554081790900335797631743704599354917110833385" \
+ "431529946758628104742509312229561143992532198765988099227018" \
+ "878514141238218580104368183434902069663104345510818435635700" \
+ "414562606631845260797394601892129923774496571513678144171246" \
+ "566200747779503333919046242725933701038577717836624878658828" \
+ "401949953074213765717982884761623247802534761098061468371860" \
+ "040646573304592111813415676017629612099762583556889291591502" \
+ "037421011749177580329597161049249542989001421868003098607452" \
+ "447624875123240558047810930160637311667163115623275956058331" \
+ "757826897673135754479768852033554041590179245281724637243354" \
+ "117485618855501973830027844010664951610244096398130144699577" \
+ "573289088165216285450511045687327534575629779122305699816415" \
+ "839649332244222046600972555138062951807105050363438375687919" \
+ "992990152747901390216324885281609322926002453655984740862104" \
+ "800118089506795694008885846789831227726569500145265086949437" \
+ "988620853249497033861484487843582927839639572167539512092182" \
+ "766072426433981477788791769424931914440282201493136920334470" \
+ "631849934882150702051061806916010852413506785949573428717190" \
+ "652565822614387096957090183695781683632118089627541885999806" \
+ "415805712006844406519039722769587152345216028824048408671591" \
+ "996748454264778680080651811924705017452522895119289297677596" \
+ "399980344578097690385847397582483006778980686294815929593822" \
+ "079423101338051192607368480059375406606683609868638996461314" \
+ "025218799102080893035335496954072017203857904998271542125754" \
+ "657205938132168124359996375519697778439582860828566963816699" \
+ "746486300437187004803313727795498535830803859623878348202161" \
+ "779205893343935527641213944242785604444240371520170466676321" \
+ "928607939131173535257360320584979666827307689152405952207350" \
+ "699524761489708601133045296730863484253942716135384938226198" \
+ "568386927589550770858283642852352203645776295407127244203589" \
+ "644784502503420416982059860877101382070973271189722892984326" \
+ "410970961430713847387443991297677367803419085937220978538980" \
+ "441628473685496662320890458789716737710737534633335780887058" \
+ "229693686098443784495418741977154423684238599047296839730434" \
+ "085083647717961771343882046771178192554297991147688856565555" \
+ "090757465961600177144271662429462033026661376496701392139827" \
+ "805716034927247277392566480664873339284583953871193119773255" \
+ "759149930467692321302473790340664010828943491220928942540701" \
+ "809650948952021861576751017761266006860909899638475036335626" \
+ "074637477900802957227409245252385131499626970250373571243577" \
+ "269099399542105493137222898746523529168177015284588584593530" \
+ "535422847893997078481093842801730870845975425823397648701679" \
+ "269953351511574749765536142563534666242970982516216461548676" \
+ "091848844824472900050116980087609760065613615848853809078135" \
+ "539024293905056113075795105768447478038151819261968647482323" \
+ "595339889631890319991305740056522600422147869065281727002061" \
+ "985563827492146406348739661318028756838105073748842194458561" \
+ "389348774902798361516170139490919233843823391129815389669442" \
+ "389886962769612654436729345525800917085158998450443138829807" \
+ "226401369403848923672976087487989192421758085312025736674941" \
+ "465891203009498155699006389389940020187366385171748881799189" \
+ "859057487614182907767561954322147267560355277722058958977274" \
+ "007000776522440864120260304346026144122668525606742093385842" \
+ "877851187985354298444881951517964028828337147992244078392289" \
+ "033891527938598539476575275618308528833647822827687596807355" \
+ "015006465320113872907922736279079949111368490254190424134142" \
+ "526305891930318351790395305770103209586168680236305757463917" \
+ "504215452060579791599906033628162787284365361089361880425156" \
+ "013152471178783132851787237084697582323149702243584748375544" \
+ "864216759785482917668710098191387194325613366050379525378498" \
+ "060821148303033711198142478670004863329544955847264359312410" \
+ "124051026217318607753467506730576567256247484381058493859200" \
+ "638791430791009825392526429942820641023745462165966092444179" \
+ "625962380866337824952291146979992952948121844170079781600828" \
+ "3296406611"
+