Keno / ASTInterpreter.jl

Gallium's AST interpreter as a separate package to simplify development
Other
16 stars 10 forks source link

Print array summaries for large arrays #45

Closed timholy closed 8 years ago

timholy commented 8 years ago

With this, you get:

julia> @noinline bar(A, i) = A[i]
bar (generic function with 1 method)

julia> foo(A) = bar(A, 2)
foo (generic function with 1 method)

julia> A = rand(1000);

julia> @enter foo(A)
In REPL[2]:1
1 foo(A) = bar(A, 2)

About to run: Main.bar
1|debug > s
In REPL[1]:1
1 @noinline bar(A, i) = A[i]

About to run: (getindex)("1000-element Array{Float64,1}",2)

which is much nicer than master's

About to run: (Core.arrayref)([0.8377075596897974,0.7007263722714208,0.5971746009538244,0.609557333538465,0.3609883049612659,0.9754143718311865,0.9828231664819158,0.29794392646605794,0.807328043903609,0.17765928341135417,0.5287921331074421,0.9964057436391751,0.46965724825696276,0.7207897838419961,0.3246225436965289,0.7036896106588164,0.3104219843933924,0.23136832888249548,0.12683860007551506,0.6343230626663747,0.3630398881881467,0.3221592309788117,0.2862546273006117,0.059031439580675915,0.08693016780244389,0.1531914784566175,0.31890608561805367,0.08174332852195576,0.10402846443563885,0.05872469204201969,0.02054991074170176,0.8776369218885867,0.8951205343595761,0.7380909404976659,0.7131183043146965,0.53209898164662,0.6009140785235425,0.8163221105378642,0.8087622101245775,0.5969554797712768,0.237547374296879,0.7878839321392321,0.40654104446729966,0.5019941175635247,0.467186861227314,0.583912434188024,0.21576256986595688,0.6232900049299479,0.7438933283641591,0.522387588328558,0.20542054524364128,0.1501983501005324,0.31934500225013207,0.39357305880611904,0.5923167271358014,0.7519684821219761,0.0020035233231527894,0.2846080613671109,0.09583119864854273,0.19082721553678605,0.7951104132919866,0.6140582496790672,0.8673100408803285,0.38053671075523754,0.5096690225140048,0.8809894987813063,0.7810186902127318,0.2243390019039897,0.7252173429370123,0.18739855431414054,0.8469722476565484,0.15807040475475498,0.886233476415138,0.9577703124446151,0.5354819923513026,0.3897641935133662,0.6576071549801001,0.03824442288888985,0.22307770176759556,0.6691784995466532,0.6808105123115027,0.8477826153298091,0.8966899081621762,0.2672439787820977,0.7342588872127545,0.9913712728524215,0.6663242728584879,0.358924596670666,0.9356891510247127,0.35552654364013314,0.7446853573387553,0.3031435286651789,0.29351111732658697,0.22919286071632983,0.6133706847379112,0.21843828291552847,0.8174487142548787,0.04797876198620554,0.6777257212555223,0.8609906604281194,0.6335567180807544,0.9073212433640723,0.5009100263261548,0.85990661923357,0.25076883901116775,0.6105971105580092,0.8881829406535768,0.22011181039110106,0.5783180163804815,0.6817625195978676,0.37439609903960447,0.5180845405025443,0.29150662186454146,0.6342512038668913,0.35542542053138093,0.7748755473232256,0.42648398193297576,0.1569789433753268,0.31134275426336977,0.20440115391432223,0.39514974714122,0.7335645219864828,0.9582106917363487,0.4196822461007148,0.03865159662873885,0.6885634364937896,0.9545287855806281,0.8985735781428335,0.11059498895645281,0.04396161812858734,0.48997754922508774,0.25051738894563025,0.8775723735376573,0.5780738541653205,0.1773041304406735,0.4952109900445265,0.5222998255164166,0.0644736491108413,0.09745587870629469,0.009970190120772715,0.2547871996881437,0.3356627142860349,0.9023576108496538,0.24256859194143043,0.7226298936280557,0.9192362742196696,0.3605672863168108,0.8734862983416425,0.4568992885436003,0.4471404707019129,0.10490682474668156,0.8799387557454879,0.10873099053348723,0.5246819175141801,0.3412647045354036,0.8760770141478889,0.8624550813416507,0.9274317381628618,0.5274669311606766,0.7385673011503577,0.2497062553541023,0.3956527729869068,0.5170719072510521,0.775832080615561,0.2516964872183316,0.1936146058779522,0.6576162210770324,0.8584908683002865,0.82999544975659,0.41919822602759904,0.7058885165093642,0.14126491157345455,0.5755792323042985,0.10724678980987146,0.001334841569934131,0.5384080395389688,0.2785660150629403,0.6172215918654917,0.26252454941114944,0.5837578229851361,0.1587278200908564,0.6216541559692597,0.9764435504867228,0.4163868662745427,0.24532906189880155,0.2421016478819673,0.7405653445857969,0.333717657055806,0.6813321897689937,0.5869407235975785,0.6866768651403428,0.7360686585595166,0.5895773701351983,0.30127797711239834,0.6377158492950756,0.6275791829014228,0.3051346274874711,0.8849367941088284,0.9117858725137653,0.2509928207222094,0.011812730367912083,0.6859291459394421,0.44532127941717103,0.09324946105714726,0.40531741716463876,0.3936924923580465,0.9398858615368704,0.0936918067287631,0.5764760842551779,0.3040921925943858,0.9041546674008565,0.600057807787189,0.31583683812270724,0.20444510398953875,0.5303807681677011,0.33075551696682637,0.04300042832034001,0.9687932118645048,0.8110751870508925,0.250258614989344,0.700552791226563,0.46052703316589727,0.5813678077890827,0.045516209524289586,0.5857577434865016,0.2240126625581449,0.20065431430341807,0.3387391769721029,0.01609627804409053,0.9733731824641276,0.2818212679866763,0.9038988875304881,0.6365933396280379,0.5903077947468578,0.1681462725585281,0.5328039656035188,0.09980540959883877,0.15854479796181198,0.2108035508227637,0.1471277008256926,0.4764033793703828,0.158232016868862,0.6886907563985536,0.7780676302230736,0.644735094343172,0.6276835498873163,0.8703245900283889,0.8144650605671946,0.657903139558691,0.6416256586152669,0.5306609729300491,0.008938433988917804,0.8904212980360964,0.16313671626782744,0.3604677391076838,0.8502045876437607,0.4718078409932198,0.19576514539516543,0.9714640320686114,0.9824073822999682,0.9115632431215999,0.17644858252147166,0.48542420814828846,0.5713720645390674,0.6144247730697654,0.3367858908522028,0.7818129167381509,0.9760608214531836,0.8193778773331568,0.6487194512139349,0.48731016138655003,0.2761078691865231,0.36030355593247054,0.09962652273629247,0.07332417609155462,0.973687093388077,0.30767754805960457,0.27198097749262407,0.8994107485101475,0.6738295237359597,0.2583332614334677,0.7434465567145847,0.9170334057143841,0.36014598771148876,0.3992399827894244,0.04574996086709815,0.9638187692989642,0.47296034436593404,0.13247582202504504,0.11607090725809766,0.391527209400355,0.19880830247144332,0.5687468811367018,0.23608105963149928,0.12166386576080801,0.8042165876816065,0.29829473252076144,0.09180348384062986,0.022571562903115572,0.42355531251078604,0.2344943888994364,0.44647838677756124,0.36585550232796993,0.2546928040426668,0.9654101519103544,0.4283093825744886,0.1954849868943509,0.8771851420064698,0.0760131314586685,0.43995930441350795,0.6612172215364907,0.9572018542129574,0.4002244953065457,0.4819826803850986,0.2824099505186566,0.2382696707828722,0.45327613344747797,0.5467083396900154,0.8523445364383535,0.8754664251549811,0.01011444393898997,0.839360728013717,0.3542482109849405,0.015146324898559271,0.09444927604860442,0.833240257900933,0.9148451864506062,0.22062395023171444,0.12006970631606229,0.7698471386459966,0.2020354069336614,0.09253024179024183,0.7422955050304703,0.3774820035349893,0.49295512604093217,0.8344150618662365,0.705601365207881,0.374536773546833,0.6553196922954885,0.03449512698623458,0.5736799278674087,0.20227400385777328,0.3573382451850806,0.8024315270318383,0.2748572151280859,0.5916855666986027,0.8503188543209927,0.9514006158361934,0.7867439761816899,0.6839768137364801,0.3576348635320066,0.3467569832001862,0.28938120012972046,0.6968429763452717,0.3870477979024525,0.05890604871305127,0.09891691040983575,0.30160182910833977,0.496695221660171,0.6480180869404071,0.4807900431964667,0.5650183878793644,0.8846483553677604,0.46906194308144533,0.3548841252814743,0.1844687452160596,0.32296746299603796,0.2710483257614311,0.880605588193206,0.415902038097977,0.4173424578323379,0.2847371946693491,0.9312859557707345,0.8188824442557145,0.692492979261013,0.6181476360525298,0.6534869170517663,0.0024255885295758617,0.7153217847457372,0.28164951271367733,0.7194019603003077,0.5083058704916097,0.9798395032266545,0.6481823244625231,0.3906477101090968,0.7643942036600191,0.22621965488821338,0.003980426791761138,0.007498053995944165,0.4287890748354717,0.16508383852734654,0.6921303266493026,0.43092905728828645,0.36746230477168207,0.6551605103820184,0.614558884254069,0.49966955557146875,0.08891792584640568,0.5658245796858514,0.4845473267979272,0.1391130017057789,0.5893053266193753,0.3888813066528274,0.2790082258474422,0.8001850013871867,0.021562125620157246,0.5701439775778001,0.17547774135474525,0.4403790209614966,0.4417706925243683,0.045343200946941,0.39932300114992847,0.34190200511503344,0.9281629199825041,0.049956161773017094,0.8106979528852094,0.7936905932130771,0.09160335003165199,0.33212995367156894,0.9920838825304195,0.7629257411499923,0.7027901626630764,0.02117287759100206,0.9870485032833862,0.2263749136673776,0.8044894833734073,0.48878845434615026,0.32193767052019884,0.5688611222189703,0.6341443194483563,0.8294543248742963,0.07654922113223872,0.9762315995084134,0.8106865526910887,0.552140532268437,0.41258319331462645,0.7783033930550496,0.5103717963719341,0.6533602623049786,0.8479263648020148,0.6455339492960408,0.032923609361601436,0.030833921772365214,0.15526577597920532,0.0925274843487156,0.476970733054652,0.7482019217739762,0.11813431182234169,0.16963072400545642,0.33361118016706426,0.9086668530365105,0.47966512963698493,0.19284628078993626,0.5130927940976278,0.5997360148035706,0.6304297140043764,0.9515100268711869,0.4914383709008332,0.4634064892237493,0.7084130861838582,0.9509932035828901,0.6905515478099036,0.9523510948467562,0.5396359664412818,0.13896828318307342,0.505193000064426,0.6890658376317114,0.5575791249794044,0.2487389026352893,0.574728377310102,0.5885630164125559,0.8149454381051138,0.3939228838694657,0.0880627965453451,0.25014640885017525,0.7028632091472728,0.8931400707282402,0.4906349077217107,0.6387841344918319,0.437509153831136,0.5628015157895556,0.6116139380486225,0.5839969799745481,0.5206520689225393,0.3125948942095458,0.6908821841323618,0.7616375620749041,0.9619383578826939,0.40099143526253744,0.06039352376207585,0.3827464557298572,0.3850584300822948,0.8937755984444229,0.9486035522573133,0.08445066676726687,0.3854211995637449,0.8589350491413488,0.09013575098959081,0.6690784410263837,0.37306104144720975,0.23945110911450573,0.512087693786027,0.4599947158651898,0.7120220501551793,0.9146222293631983,0.9842925279453987,0.3304788869520583,0.3934442117960497,0.254987641987398,0.1024449339521365,0.11468897309918202,0.43925365984780185,0.07549586655048235,0.022631407431607187,0.2418802846085104,0.3571758204000979,0.2724623514670539,0.6356252350907663,0.48262840359693304,0.6427963911276984,0.4427898349072499,0.2159574522037333,0.6497731913757869,0.8483492090543294,0.7892555250837205,0.12287055067216923,0.915920912999292,0.18928124579505345,0.6591562346019113,0.990048090118282,0.42901255676072325,0.6122363991159783,0.7549462832951073,0.9064391428473175,0.8232121078899153,0.41339336445941677,0.06505617272704889,0.3237870337767925,0.9308494462462793,0.5021563662381221,0.4441432192573682,0.17936702158061002,0.7548172365593577,0.11786923584485987,0.5903716811964355,0.9469217963787586,0.33177814371612113,0.004987856206132957,0.05357739865501876,0.2001445765604164,0.5521597251412498,0.9916291335000953,0.4261278155333017,0.35632777508615776,0.7190460286755613,0.1252093172420683,0.826184576472214,0.53282473619813,0.6689264545973934,0.5714447234736759,0.1317336567028351,0.3255920678210824,0.4228178993595333,0.3789065963436027,0.4541675868305872,0.023429288057934317,0.43611093751063335,0.0775487039504088,0.9837720526214897,0.8273272579025333,0.7931126189141333,0.7252280346430391,0.41328196257772,0.04978134982471927,0.03574661092460185,0.13955428914072998,0.47663592063006965,0.7257070529017886,0.007475437136594598,0.8675226286120203,0.9792007391913484,0.9967452859000563,0.48895528439503,0.20141424234585714,0.5489469118702,0.883476059256997,0.8218922253931138,0.1844608132382024,0.8711140300839684,0.4921378779471317,0.9623389323535165,0.31471634493535094,0.9362596498858435,0.8913461244750815,0.2717229729376145,0.9466674111783708,0.5628547923009901,0.5132914631531089,0.5638461835412314,0.9789103998232145,0.7640153847472615,0.44981989142224044,0.0048521238181242765,0.06128373328518033,0.48105244860545593,0.4266136670437637,0.2076969414005816,0.20499000873011042,0.023287471630801804,0.049205818061161644,0.19898545533592693,0.5359420687794287,0.926931359902115,0.4735343355676829,0.6541182645547421,0.8489747195894031,0.7916406915370315,0.8475642386703441,0.41760027085768003,0.4334463298458695,0.5645401686576885,0.5103161525515028,0.8530919231131713,0.7581621055742487,0.38782529023551326,0.8048886545851957,0.4965554892327966,0.6207430806862511,0.9311713380126552,0.36313619210127457,0.1396554286109597,0.20080804118851026,0.19477223527704113,0.22356727402397802,0.43460957876254036,0.8059278647270045,0.04516674911116647,0.7532648226511882,0.34212473078087546,0.779288888781744,0.1056669210491159,0.2331302825635817,0.7063305436383394,0.9347921671469956,0.07351181334870716,0.47881734398848486,0.9325650417292519,0.4852408343987824,0.8217101743988104,0.8843312718270391,0.47051568891346984,0.852134731054836,0.32482941763500395,0.7928503972536736,0.9284847903664541,0.825721339481607,0.7322751115223889,0.13188238710085765,0.9346600630936446,0.49572769113521353,0.3307960890301629,0.06646707631624671,0.2875921329111668,0.41736335219005216,0.4412740275160427,0.7644769675521241,0.23692620552905708,0.3001684296680003,0.04520645503592813,0.5650763933541054,0.5581371446551753,0.18415572172500183,0.9646400032423408,0.31087010263294435,0.7181405011520816,0.9829331779437591,0.5159057665492675,0.664872722195563,0.76149852078036,0.6651105977929079,0.03253530657725956,0.44378384967972706,0.1992256181780856,0.5431517488663484,0.1302943772952132,0.14884645607579783,0.5409286799227151,0.6356127124545286,0.08202655909853984,0.012439470516385942,0.04252656996518156,0.2868791957736363,0.7694495511391881,0.34037940528721133,0.5740103669801302,0.3342614607039345,0.9957147452937105,0.48034801217761625,0.10476338917754835,0.5351040347446581,0.15048614726582765,0.3845102582421942,0.08980108338743276,0.5790456523015388,0.015507173090911985,0.9113528024706186,0.34308238694770044,0.6207855282092354,0.5617793176211516,0.06632278759181043,0.6962095613641246,0.9764637885776095,0.5199211363730654,0.428408940920904,0.36365273838782386,0.02940556590594734,0.9616362802405116,0.31691170947479064,0.30302795252280057,0.9437079612989194,0.22086906224142178,0.4965859237624606,0.2298792459405934,0.8046865930160336,0.540131810019642,0.07377365532884261,0.6265700899461835,0.31603165863352434,0.7963354453378018,0.9154701949593373,0.9217272086033326,0.8685893071552797,0.8735206173171421,0.6849246669799032,0.549712599479397,0.9859081888640053,0.2006214719303534,0.18733941351782257,0.4631828513489402,0.6673468213099474,0.1490589551088768,0.18972129805527072,0.15704149393324207,0.06879580352196757,0.42181961306994964,0.035828566050728705,0.5129567238791,0.9717546363090415,0.14906104019893185,0.4882156257690249,0.35939968958917823,0.9176202161452114,0.7052517551600721,0.1866279365793102,0.3838716251459051,0.44784473964812843,0.7936542440406071,0.3065580709044955,0.531834080799739,0.5758105959018924,0.015962158373269197,0.5055063700013998,0.17323725092399278,0.4110201143895025,0.18105168221948742,0.5093772884914565,0.6467515167798434,0.3565593508020388,0.24127791787933894,0.7723269623414846,0.39149805428739937,0.4730343933561383,0.2962498280761785,0.39923443295012184,0.10450975583339606,0.4964516144584221,0.8979643559064814,0.09167123443715441,0.3928840867108099,0.8013557543346017,0.5245986976740806,0.31565618439806986,0.2864791576862056,0.6949525377713239,0.5481830893473174,0.3657598078154489,0.1019710735795556,0.07179846713772209,0.6512971356006574,0.11552051382902051,0.6600053250694768,0.9368804468128302,0.9592375055387665,0.982736137392124,0.7007905181406604,0.521151724267997,0.73493748836157,0.2765781163671641,0.41509609698119676,0.8153441583550312,0.11215833768159889,0.6153343349446017,0.26266259043230966,0.5110323290322056,0.2237206772472362,0.3319309685826899,0.481222102352751,0.7348699313670655,0.08201439634066099,0.1508335451448113,0.24149331961143705,0.6115151114619415,0.9015251043689498,0.9969077676422289,0.21192425402630977,0.3388973643585398,0.3818779243506798,0.07633586955223559,0.05926182376610423,0.789093180922017,0.8423967576408704,0.7973319719818541,0.3265279572616595,0.7788507115968968,0.10824624466545063,0.5722051276581435,0.8761239675679657,0.7055920874351163,0.06623424763909536,0.6005896667810438,0.03002670259815865,0.6656302986355258,0.06869211368612249,0.028728699110183387,0.5861827841161666,0.812709467193917,0.5411996145016802,0.9513176321971932,0.9465776253786644,0.8946786280625307,0.7300383224027636,0.06442741978470079,0.500211657218878,0.16111924029162394,0.5037175145882582,0.7291892731015457,0.5801856031425112,0.023196645694633755,0.9773019187605025,0.9308261956241863,0.23882749705240136,0.5890373032371017,0.7978178722147895,0.4893012826510734,0.7090818641072434,0.7702453787605228,0.8358858855096158,0.060956538433784235,0.5686481595194179,0.7614768886358165,0.1598490214094248,0.47578450697329333,0.23669087334372585,0.6734333944568578,0.7357631405326486,0.8749801943347209,0.35958274167892945,0.9131679254704308,0.36616575870460455,0.107917601201859,0.515255673522818,0.840712091139433,0.05998028862643623,0.20216612477012275,0.25725563434263643,0.5345943544169298,0.6179088394789609,0.16172877993330492,0.5847623725043403,0.953722323550289,0.61384741870759,0.7780899040829321,0.441044361123333,0.11527742392426354,0.9214991407485125,0.65424774872305,0.09803459123052471,0.40138046781848624,0.23946966376085865,0.35401177041413634,0.2070878122032931,0.7817382628814289,0.08825190388505999,0.983465894844447,0.011083201090487105,0.08428120609759793,0.9505371044198216,0.7116651638958493,0.3875494154911743,0.4210824313223338,0.8471022690563523,0.45249393958643847,0.8598571246708424,0.37499054230200524,0.1474924309866279,0.17651770115519305,0.19141070487011058,0.249033427255954,0.1293391565530988,0.7462971165260626,0.671259095706926,0.21199470992694724,0.8697759625000359,0.9181099746142951,0.7878131878668058,0.7045158747132345,0.14463751951654524,0.578281270902153,0.39664404412469056,0.8529769981931286,0.4669599757804803,0.9765482927123876,0.6031831073639853,0.7749208725860046,0.6783461159147646,0.6183003298733167,0.8973620679350274,0.7892446313025208,0.9768870727896855,0.5834065716413881,0.7365864609746808,0.03493668222112856,0.7273245225589249,0.6412930063442386,0.07415105144285006,0.8315864471094749,0.17160586521951826,0.9457530508629384,0.9592991989177921,0.40502949380916764,0.7231724733530669,0.910608880410718,0.7692658650717921,0.7520805868359366,0.010809467984807863,0.5533192060391185,0.6616243098032621,0.21276267683590033,0.6174197766208349,0.025958250054455734,0.003965771152654618,0.24924846128951006,0.8830909528233781,0.5021241521887583,0.17530798227055544,0.56735247315325,0.7198234731489492,0.6153990301650607,0.7225665149175147,0.29295580258439724,0.19199240838549247,0.33207502365730823,0.15430627418776122,0.5408011490904212,0.8742584722551894,0.9628625640729145,0.33645413583288875,0.8733157932854885,0.31959138606281123,0.4343229918192262,0.3826287878540051,0.37349542609765374,0.13605150596885718,0.6798467299398592,0.8354134618298745,0.9932664693179787,0.3870489748573549,0.7705318361546993,0.2981821294521123,0.532221413944163,0.1709024531821215,0.11282601422742577,0.26052836529142165,0.33305838105224694,0.2314122914155723,0.9482466824307789,0.856033005702789,0.8478771819060822,0.511906761767716,0.289185849686898,0.09938176013896483,0.9867533481963242,0.8550103807092686,0.973778895467537,0.41739493678266926,0.43114560260416335,0.3432157790698347,0.4670259037555369,0.42439389025685004,0.6504363166418801],2)

particularly when the array has 10^8 elements rather than 10^3 elements. Even with 10^3 elements it is several screens-full.

Keno commented 8 years ago

Not a huge fan of the string quotes. How about using sth like:

immutable Placeholder
test::String
end
show(io::IO, x::Placeholder) = print(io, "<", x, ">)
timholy commented 8 years ago

I mostly expected you to say that. The definition of show you suggested will StackOverflow (print is defined in terms of show), but try this on for size:

About to run: 
(getindex)(<suppressed 1000-element Array{Float64,1}>,2)
Keno commented 8 years ago

I meant x.test or whatever I called that field ;)

Keno commented 8 years ago

Nice, I like it!