mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-10-25 10:17:02 -06:00
The operation budget counted each operator once, however long a path it made or read. arc and arct with a huge radius make up to about a million curve segments, strokepath makes a piece for each dash, and rectfill makes five path elements for each rectangle in an array. pathbbox, clip, clippath, shfill, pathforall, gstate, currentgstate and setgstate read or copy the whole current path or clip path, and in an encoded user path a byte of the operator string can repeat the next operator up to 223 times. In a loop, each pass counted a few operations. vectorcraft-cli info was still reading each of 15 files that run one of these in "loop" when "timeout 300" stopped it, after 28 to 128 seconds of user CPU time. With a radius of 50 instead of 2.9e30, the loop of arc ran out of the budget after 6.9 seconds of user CPU time. Each of these operators now counts the path elements it makes, reads or copies as one operation each. Making or reading an element took up to about as long as an operation in a loop of pop, and copying one took less. strokepath also counts each entry of the dash pattern in each period of the path. An encoded user path counts each entry of its data array, each byte of its operator string and each operator it runs. The 15 loops now end with "the program runs too long" after 0.06 to 2.35 seconds of user CPU time, and the loop of arc with a radius of 50 ends after 1.9 seconds of user CPU time. Tests: a loop of each of these operators runs out of the operation budget. The loops cover arc and arct with a huge radius, strokepath with a fine dash and with dashes of length zero, rectfill with 2,000 rectangles, the eight operators that read or copy a path of 10,001 elements, and uappend on three encoded user paths. The tests read each program on a thread of its own and fail when no result arrives within 20 seconds.