Here the source:
rebol [
Title: "1000 Cows"
Date: 4-Jan-2008
Purpose: "To measure update speed when 1000 Gobs are animated in a window."
]
cowcount: 1000
krava: context [
imags: reduce load decompress #{
789CED9DCD8EDB461084EF7C8A0DF202426204B907D897307CF0C13082C0F700
41DE3DF0925ED5B0A79ADDE4903352AA1710762915A7BFF91335534B7DFCF6F9
AF2F2F7F7EFBFCF5CB4F2F1F3FFCF2F7AFBFBDFCFCCFF47A2024965862892596
B8B9F8F7DBF79F390AF10DE294927B8B919C8A23B5F040CC8578A69AAB81BDC8
768F16258F218EF4EDA293F8559528B9B798B56A458C0320CB3F143306F2DB98
D81311FE6199E7483363F44BFB909832CF6DF9C76DFD331FC747CBFF70CC33C8
843C73C4F927BF1B3448FB9078839951612DD8D74C33F1FD716B30A4D3DE2966
B433C8E4B7A7AD85FBEFEFCC78687DE4BAC9A03672D7CC453B47FA33EDDB96D6
EF36AD99239C156646EEF33B6F745E8515E206CC48EE27BCF46DFFE90D667F5A
6775511955B61BA4996D99741ACAF66ACAECF3DBBC264C6CFEF92EFFB03CFAA7
48CC61166DA36F87987D194BBEFA31E1CE8CE4F61489C9C092B7EBDB59FEE047
E03AF9CE09B0E86138DC1AF4ED087F620E5B4F0BCE9A41248A4516FC3D947683
81C17A6F28ED43CC1871FE89F5DE087FA593C4C9CFB988B3F56FFB3F9DF46D67
B443A8D2CE71FE6B2FD6F148E5FD995F7BE194FC56320A58C5D892AF62C6C02C
8AC920C28FE4135680E5F48F775F7DF493648D37954D1FE52F66921ECCF84784
1F8F4FAC0344F88B8B38DBF513696763E7D5101D1825FF1C6BFEA59D590788F0
F718180BB34D32CE4FDB99758C0669B713EF4BBE32AAE2A7E8CE8C7133C18E87
2E2BD829865DC6F393AFBC63C44F5159EA689676423CFDFBE945062189259658
6289251E401CB9281830ED06629F7CE3E3EAA192C7105B9CF485F5CE92C7102F
17D659417161BDAFE441C4D94F02C5279143258F218E8FEAE77485DA518D2123
5820AE4DFB90B8D6906F62FC23B2B786E4C33233DA6215DC3EEDF32F9DE4C4B4
D362BF7B524FC07A9FA1E6FAC1E393BF789A4E7BA738C219DA2B8EF04FF68938
FF39EDEC6F71874C146C3F316428F0F9CFFF8042B7B8B33E808A0F621FF95573
98456BE183F0AD0476EA3B9FD9F2173E8888D325C41CDB56BFFB7D7A5CF51625
473A698299F770B3B9BE8FFCE10C4295DA2E3BC635CC18717E1984AA6FEBB528
98D9D8F2F965103A831903B390418824C91A4F062119846410AAF0CB20943C45
77668C9B09765C06A1E4296410925862892596586289255E47E59AE9A2927B8B
1317D68D4B1E443CB3FD1FEF14855411D7C7462749943C86D8DE2969431CAFAA
8D92C710EB4E51616616D7A67D485C6BC83731FE11D95B43F26199196DB10A6E
9FF6F9974E7262DA69B1DF3D2BDB80967C6ECDF991D5C220AB6611CED05EF11C
F7DFAD0FA83008DDABE97A6624F7B7B843260ABFDA26AC802CFF431884E8C0D8
328E5CC93C872547B4B40F024F57A9B0FAC4D073ABC4921F3308FDE0B9EF1B32
F231DEE896A6F247ACFF583114D85A401F50B5C22E642EC4583EA6E7F7F68D81
616BA11818F1A17F0E33469C3F6D102A986DD3C7C965106AC58CC1F865100AF0
CB202483900C42EF083208C920F4BAEF14DD99316E26D871198492A790414862
892596586289256E208E5F510C95F621718DB9E93DE507145B665CA32C9662F6
5D5E9E93762466A3C3F2CD68D6F560992B9B71B61AE2FC832C3F6D47B97B5AF9
760A360C5AA77D481CE75D2F39BE96DF2AC4566419F920E399A5C76A21743389
C199595066BF1B602FB0E40FC74CB74AEA7B2E35C7C0B0CC8CB698B7D9AE92BF
F334D40A12EBC9B60B6F7CAB10E32F98F7910F6810623BC678BA4198E7C086F1
5D122113058B8DAF184BA7DD406C3B66A59D7DCB40C24491E57F208350623218
63ABC4920FF815638D993196211999E8D27D3BC2DFFD8D0ECB47FE8DB41B0C8C
7D53FF031984363A499C5C06A156CC188C5F06A100BF0C423208C920F48E2083
900C42AFFB4ED19D19E366821D974128790A1984249658628925965862892596
58628925DE12B39B67F91F26BBA7DD40CCC83142CB12E9924F11DB35808D9585
F9887FBFA829524987D2DE29B69C1B0621B6F2BE5172F62E6CC31A84CAC775A3
8696DC18FFE00621C69FBE9D18F20F6E10A2159665C678068390A50AB911E697
366366E458FE9906219F9F1A0A22B5F07006A1A56FB373CFC4F7C75A2D3CB641
084B465AEF489BC9006B12B3080DC94303C34E03D8B248BB214E3363C4F9CF37
08B15E788EBDD25661A5E4C8EC6583365524F9F9786560D85C582F781E8310BE
14C9B1E425ED08333BF5E006A15A6D1FFF8739D601228D77AD4168D554D17F15
AB30B3B34692EF6E10B24D9266F6C3E62883103C11E1974128798AEECC186C84
D9E33208254F218390C4124B2CB1C4124B2CB1C4124B2CB1C4124BFC8462BBE2
515904DAB7143414B3CF39C7C63660A4160661F609D3FBE37E5D145F3E6A2BC9
AFBC010D4221434159AB233824B104BAC5EDEF80270C05B57DE35E0E494B8EC9
270C7F1543417C486CA47DA243D292A73D3EC5C0B04F73D9080EC965549525AC
D9427E977CB50DE190C40640FEC478662F65C7877248C6F9D306213AAACAF60C
D736A67A88196919FF5506215685E75F4A31FE6B0D4218D421997EC7C8F27737
08AD9FE60EC18A785F0C65105A9765FDA03F1EDB6DAE47F8F1F8F906215BDBF0
8E61ABE4490D42456DB3375AFF148F6D10C253B01F7B8AE73108DD206AE3EC80
2B94A66D4BB6C9639C6F1062FC8543B201733CF96B0D42950ACB9EA2C22C8390
C4124B2CB1C4124B2CB1C4178BED556CB10D7862C9FDC494795F3C0473426C09
37F659E2557566DACDC4B49D232BA2B82CD2EEDF27B382B49832DB6EE0F35736
20F7FD13650F66BA55C2F70DD78FC37EDF20A32D9A8AED2AD597FCDE57C15907
B06B64E733B39E8CCCB4A970A5D06FFFCA2A385B17B62D3F8841C8AF2A1B1BF7
4660B4AD9991DC1F9274F732D2540B73A46212691F6246729FBFF51D84E2FB3C
57CD619521C9DA76E7BC6D658CFFDA0B57CC4E5F3116EED59439CEDFFD7FA9B1
7CE4DF48BBC1C0884C77E73063C4F9F51563C0C6DEB7F014FA8A315231B6E4AB
9831308BEE06A17DF13C06A1AB98F18F083F1EEF7E07A17DF17006A174DACDC4
0BB34D32CEAF3B08254FD19D19E366821D3FDF209448BB99D84FFE49EE20F4E9
3F8F0ADC94E8FC0000
}
explosion: reduce load decompress #{
789CED9D418EE4B81145F73A451BBE40C21E18B31FA02F3198C52C068661CCDE
80E1BB1B5D52B5828CF8C1088A12A5ECCF02B2AA94F9C578C1205329FEAEFEF5
CFDFFFFDC7977FFDF9FB3FFFF8CB975F7FFADB7FFEFE8F2F7FFDEFF2F540A398
628A29A698E2E1E29F5FDFBED656885FA29DD2F36CB12487E248161EC45C8857
AA350DE845BA3C46F47C0F71A4B68B22F15395E879B6188DAA21961320CB7F2B
66D924BF6E0B7A22C27F5BE6B5A599659B17F62131645EC7F29757FDB51E978F
9AFF71CC2BC82279D6E6F3AFDCEBE3E215C190B00F891BCC6854657DCBC74DAC
9FF027433AEC4E31A25D8770F1EBD9CE4235CEBA0022FCA39935A7662EC63932
9F35BF31CE91B219CD1CE1349811B9CFEFBCD179092BC4039825B91FF056DBFE
D30D667F5947B93066952E8334B3EE1305BFC447B5C1ECF3EBB81619D8FAF54D
FED3F6E89F22B18669B4466D8798DB6F6E56F0E6C7849D5992EB532416034D3E
AEB6B3FCC18FC03679E7025854989C6E036A3BC29F58C3EA65C1B9671069C54D
16F97328EC011303556F28EC43CCB2C5F91754BD117EA348E2E4E75CC4E9FCEB
FA878BBE2E463D858C718EF35F7BB12E8F18EFCFF8DA4B2EC91F3D4B014A8CEE
F92A66D96414C56210E197E48B4C80E6F48F4FBFFBE80789066F29873ECA5FAC
243398E52F117E797C410510E12F2EE274E927C2CEB6CEAB2138314AFEB5D5FC
DB38A30288F0CF98181BB30E32CE0FC71915C680B0C789FB82376655FC14D399
657BA9868E872E2BD029467F721F26F68337DE31E2A7306E750C0B3B215EFEF7
DB171A8428A698628A297E809806A1F005D7B09E6F225EA96810F21A0D42A2D1
204483D09CB00F8921737C8765A5978F8F6386DB069A0D9117268A53C23E246E
30A34D22CD2FB3000C4203C3EE1423DAE22E7864C7D0A86D99009B9F06219905
1A848E304B723FE0D1260A8D807261CC2A5D066966DD27DCE2CE5675637F3CB2
4B2C26060D423408ED59D0E43408251B0D425FF728E4CF088A0621C1A68B514F
211A84406274CF5731CB26A3A041080489068F06211A84681032F869104A9E62
3AB36C2FD5D0711A8492A7A04188628A29A698628A69108A341A843E1A0D425E
A34148341A847E4C831072095C17F621B1CB8CD9F6BB098E89E2C4B00F89ADE2
FD10D7F75F33FC46C206877D48DC60B637895AFC9529AA4EDB80B03BC588B6B8
0BEEEF1822B4804108F33FC820D4A8ED36FF3B188470E937369A65020E314B72
3FE0D1260A8D80326FCC2AD93A99759F708B3BEB03089928FCE0D76769107A7D
4E0A1A846810DA1B0D427DCCB2C5F96910126CBA18F514A241082446F77C15B3
6C320A1A84409068F06810A241880621839F06A1E429A633CBF6520D1DA74128
790A1A8428A698628A29A69806A148A341E8A3D120E4351A84D465B57EBC2AEC
61E2DA20647E808A90EBC7DB32AF0D865D1FCA903FE62FCB343D01F271BF9B10
4A58867F9629AAC9ECF32FFA6571FEE906212B540F47EC21C6049AFF5606A138
3F340845F86F6B10F2F9BB0C42D562308039C299D82BF6F91306A186F810B324
F7B7B847982822E3A9330F12F6D93A9925B9CF4F83509F0FC297A1E069105241
CA2C68721A84928D06A1AF7B14F26704458350F5568E1B1CE7383F0D426730CB
26A3A041080489068F06211A84681032F869104A9E623AB36C2FD5D0711A8492
A7A04188628A29A698628AD1C587F5D2B44168FD5D3F9E13B6EE33244641CAC7
B04128B83D140932C11C8928B1DDABE30A19844A715124F5D9E35938A7B623FD
A70D42F2840633EAD5C87694AF19B61762B0E7844128535DF5E9AE652E26465C
58FEF431CE2FD550857F12EFCFCEBAB310D8A5F65276CC20D417F6DA8EDF666C
4F7D7B08471B84AE62964C355FC91A18E70CFFE24F033F0BD72F06DFB74A5001
F83886A1C07FBBD3FC57DE4DF9ECBFBA0BAE93D2E66F1884FCF19F61102AC296
69D05940C3F90E06211D98CF3FC22094590200B324F7B7B81B260A2B92FDB7C6
7CB6A74A5561B172B0B370BE41480E9E04ECB888DB232AF61C5AB435F90C8350
519E9171D6208E41C84E92A44F38E734F908831026FBF6FDE797EC3BB086C941
B2DE7644C25059F8FCA30D42F1B14EB9BC6BFED075186A57198412CC91E043E2
06739DD318FF5506217D14D636629647DECD20142A12248EF03FC820141AE708
3F0D42204834783408D120448390C14F8350F214D399657BA9868ED320943C05
0D426F235EC7CEF8B8BA1E890C6DE276725A7CA8E7901885372C6C7DA2E9CCBA
45F83B1316AA30BFCECEDCE2F683376E3FC5F9E1BDABC89119DBBD45D83A307F
C08A71F64FA165A1B0FDD63925B7B0F5133ABC44C2E2FC13FF364296B348180E
F8B5354B5684EDF703C3EEA32DC246FDF8B134EE5DC9DFE411D8B39FE101CC46
D8FECF067326493596B955E2711A15768859B750B6E3636B30FB4F5BCFEEBF87
7C10E878C3B3E767C131397A08DFC5D1F4C022F10706E184DEE850DA42EB36C2
31EC1BFA883E6E32DB19468FE7981C719EE15045032E7A4669F34F37623140A7
C01911CC7E7A1ACCFE238A639C292A124523EC5616F6E38D37BA60B6DB25D160
D60D894343D528CFC8D46F643B97AC20B39F0B58249151487B028C84C505927B
ECC7FE329FFE683BAB671BA453BC85ED1541905973A22DDEC632846291380DE6
B4D81AA43033EAB9DE06FEFC9EF066EAE3E97F476088FD6980F8C377843B96A1
50D89147636264173DF97BE79698D8D5FA3C1F9A00A1354CB2F9E4E3B29D6DEB
69C5CD7BCB02E48F42E30AD0CF48E39FB93416C09A24435E6C89F9B99579D998
E38511AAED08F3268E84DA60AED3F67AC99FA541489EB428CF72A36F7F942E46
F9FA746D83A18A8FAFC32C69117FC12C9351DB2770A9C08F8391E5A1F146971E
E7387FC3B4EC93038350EC14F08206F5265F33CE2054878ACD8F9B41A80E49B2
B5F88F6DB3455EE48AF740F6C0EC412A7FFEDEF3E7DFB3D359C53F2F7A71D10D
3D7BA541A88C65299FD8C923FC4BFD446C9C857808B3DFD6F8E4E81857436DFE
6A31B08B6160D8C3C46B7C60BFAA2C8CF235954108AD612DFEE9BBC075F0E5C4
40A31DBACB8C4E319D59B6BA54117FC39C5EB6FA14EF6410F2C6B97C250D4214
536C363D89AEEAF95AF1E0592FD3A64F7CAD59C611CF5AE99E205E73D321DE73
BFC4E68FDDA67BF6FA2E03CEB921D26ADF2F017A4F303A6C3D0D672C0669B1C5
6FE7E4E6FF3150425C5F2196CF48CC113775FBE4131386028D00383DB7E5CE76
6FBB8DBD3268DD0AEAE8B9AEAD94D86E236E33DA2F6A1DAB8AA47EDA4F5EA741
68EB39F2526B0805330A5ECB60CF3EBF6EE7DF354BBCDDA0971A627F243194CA
F6A1D5D31F183DE69D3EC546792241552476689188126E41236CDD43D99B3D49
0BE6C8681BCC96AC154D90193563A82CDAFAD108BB0CC81BE32A611E6123617D
CC8558F6A5C38561C7CAC3C6491884F449CD0DC824B3E6A441880621A7E74814
69666362A07E10AFFCFD1D0C4228318D6C671782F5B43408B90323F3B2319F68
1042E49BD81B8A56161E6510DA7F4B5C4A8598252DE22F98671B84241BEA53BE
8606A124FF3B1884E23221DE03D9037BA8412894B05AE0F397A75ECAE57E9E41
C896A013BD9341282284E2765BE3BBA541A89DB8F73608D9FC0F3108D5477E34
83901267F9C76D2DD2204431C51453FC18B17E8FB9AAE7FB89D72C3CC238A263
7C5CB63BC50D6699187F086FCEFCE34EC9AB6AFBAE45B22D43FA504CF8F179C0
3EDCBACD7728EC71621D5284BFF3F3FDAD16FD18F97EACFB7EDD562435753CF3
674E497C44D576E414B0E708EDB56FB168B4D3AB67D1735F556FE25E6197F89C
6CEB1AEA16277BCEB6E65079CB54E88DAE633EB797C6EB8AA48EE2DA6B92193D
EB3846F69C7BDBBBC1556FCF5A36FD8286628A1F29BEC7A2DF253EEBC2B5FF62
EA2A66FD38FAAFDDDDE91D636D90193DDD7D353434EC43E2D038C71F9FFA3161
00B35F2AC3C21E204E845DBE667FEDB26F23B768F5F18913A335305E068A5B1D
F1F2287AEE0CBB57287AF6C32B4758305B056067A13C11E87906B36C910A87E3
8CD2277FBF21332237C6198D303AB231E31EF6E3E730FB847E44C638474E6588
75607E154CDF04C1F5ECD6369AF491FEC72D803408514C31C514534C31C51453
4C31C514534C31C514534C31C514534C31C51453DC238E6C5819E2F83ED7AD98
F5FE2802696C715FB5DD3B409C66F61B14A3DE22EDCCDA0EED52A32459E2FDB5
30DB9DB32ADE426254B68BFFA2844128DBFFF489E197041AEDE6FF38BD1F357A
EE9B1245D87DADF147BDFC0A5FB40FC29F0CF2F8C471F6338C10B6B0D108EBE3
FA44C64AE2475184DD476B886323BCBF72B138DBA732C488D3E97910B3DF74FF
D550B593558D735D0088D62892487984986910A298628A29A698628A29A69862
8A29A698628A29A698628A29A698628A29A698628A29A6F86C71FF26F7CD995F
A015FFC558CB72767DD86971CB11F1C19C35089D1FF6003142A8EC1BF5CBF471
C3FB7162D803C4C8D0B2589C5A626764B1CE3B34EC616219E1521E6AD578B741
6840D8504C8310C514534C31C514534C31C514534C31C514534C31C514534C31
C514534C31C5141F13BF445B5EAA9DD8F36C71C1FC0BF8F2B3F038E64DEC33FB
FC4F6596BF207E7D7C2B92373308494ED496FDE94F090D423408D120B458E71D
1AF630B18C70290FB56A9C06218A29A698628A29A698628A29A698628A29A698
628A29A698628ADF5FBCDEFA2EF6C72FEA799ED860D63BA37E2E1EC7BC891133
DA319659782AF3FA2DC2ACBF96BE29312EEC61E238FF12B7899C1FF630B1CFBF
F8297983C540F2170BA03688E84542F33F8259B68DD9B7C3F8FC8F632EC468B4
11FF3631A4916E46D8C3C4E905F09378FD2E1FAF0C7B80580394305B6DEFA3EC
BFF4AAB0078811C2FA330D42C5687A636F884F097B985846B894875A354E8310
C514534C31C514534C31C514534C31C514534CF19B8B5FAA19FF7EBCBE7B36A4
E7D9E28239B22586B2F020E642BCF2C4F686EB2C3C9579FD2649E2FCC57EDA8C
B08789E3E4C6C47883C5C0E76F2C067E166ECB2C9BE42F167D79484F7AC4FF08
66D98A451FB1F9FCCF36CBA0D146FCC6C4C8F24F675E9B1E4F9FDF789794EDAA
B08789354E7A01F4C96FC82C1BE20F2DFA88FFE6CCB2C1F99CE57F1073218E4C
003831DEC02094E5A741C87DE955610F102384F5671A848AD1F4C6DE109F12F6
30B18C70290FB56AFCAE06A1DFFE0F5C48D263AED50100
}
anims: [[1 2 3 3 3 3 2 1] [1 5 6 5 6 5 6 5 6 5 6 1] [1 7 4 4 4 4 4 4 4 4 7 7 7 1] [1 2 2 2 2 2 2 2 2 2 2 3 1 3 1 2 2 2 1] [1 5 6 5 6 6 6 6 6 5 6 5 2 2 2 1]]
]
fps-meter: func[/local] [
if not value? 'tim [tim: 0:0:0 st: 0]
if (now/time/precise + negate tim) > 00:00:01 [
tim: now/time/precise
fps-text: reform [st " fps"]
st: 0
]
st: st + 1
]
;make the background transparent
foreach i krava/imags [
repeat n length? i [p: pick i n if p = 255.255.255 [poke i n 0.0.0.255]]
]
foreach i krava/explosion [
repeat n length? i [p: pick i n if p = 255.255.255 [poke i n 0.0.0.255]]
]
either system/version/2 = 99 [
win: make gob! [text: "One thousand of innocent cows dying." size: 1000x700 offset: 10x10]
gobb: make gob! [
size: 1000x700
color: 200.200.200
]
gobfps: make gob! [size: 100x20]
append win [gobb gobfps]
gobk: make gob! [offset: 10x10 ]
gobk/image: krava/imags/1
kravas: copy []
alive?: copy []
loop cowcount [
append gobb make gobk compose [offset: (random 1000x700)]
append/only kravas first random krava/anims
append alive? yes
]
advance: func [block][
block: next block
if tail? block [block: first random krava/anims]
block
]
view/no-wait win
forever [
kravas: head kravas
repeat i length? gobb [
either alive?/:i [
kravas/1: next kravas/1
if tail? kravas/1 [kravas/1: first random krava/anims]
gobb/:i/image: krava/imags/(kravas/1/1)
gobb/:i/offset: gobb/:i/offset + 2x2 - random 3x3
if (random 1000) < 2 [;cow dies
change at alive? i no
kravas/1: [1 2 3 4 5 6 7 8 9 10 11 12 13]
]
][
if not none? kravas/1 [
gobb/:i/image: krava/explosion/(kravas/1/1)
kravas/1: next kravas/1
if tail? kravas/1 [kravas/1: none]
]
]
kravas: next kravas
]
wait 0.001
fps-meter
gobfps/text: fps-text
show win
]
][
win: make face [pane: copy [] text: "One thousand cows happily dying." size: 1000x700 offset: 10x10]
kravas: copy []
alive?: copy []
loop cowcount [
append win/pane make face compose [
offset: (random 1000x700)
image: krava/imags/1
size: image/size
color: none
effect: none
edge: none
]
append/only kravas first random krava/anims
append alive? yes
]
view/new win
gobb: win/pane
svsp: system/view/screen-face/pane
while [not empty? svsp][
kravas: head kravas
repeat i length? win/pane [
either alive?/:i [
kravas/1: next kravas/1
if tail? kravas/1 [kravas/1: first random krava/anims]
gobb/:i/image: krava/imags/(kravas/1/1)
gobb/:i/offset: gobb/:i/offset + 2x2 - random 3x3
if (random 1000) < 2 [;cow dies
change at alive? i no
kravas/1: [1 2 3 4 5 6 7 8 9 10 11 12 13]
]
][
if not none? kravas/1 [
gobb/:i/image: krava/explosion/(kravas/1/1)
kravas/1: next kravas/1
if tail? kravas/1 [kravas/1: none]
]
]
kravas: next kravas
]
wait 0.001
show win
fps-meter
print fps-text
]
]
Really nice. Your code implies that it should work with rebol3 as well. Last time I tried it had not implemented view (windows). Is it now?
ReplyDeleteYou need to downlad the rm asset version: http://www.saphirion.com/development/downloads-2/
ReplyDeleteThe code is not mine, I'm just a curious thief
ReplyDeleteHi Johan,
ReplyDeletethis is version for I'm not sure which version of R3 (some two or three years old version). You can find version for latest R3+R3GUI on https://github.com/rebolek/1000cows . There will be probably some updates soon. (I'm the author).
Bolek