<commit_before># Copyright (C) 2004-2009, Parrot Foundation.
# $Id$

.sub bench :main
    .param pmc argv
    .local int argc
    argc = argv
    .local pmc N
    N = new 'Integer'
    N = 24
    if argc <= 1 goto noarg
    $S0 = argv[1]
    N = $S0
noarg:
    .local num start
    time start

    .local pmc A
    .local pmc B
    .local pmc b

    A = newclass "A"
    B = subclass  A, "B"

    b = new "B"

    .local pmc r
    r = b."fib"(N)

    .local num fin
    time fin
    print "fib("
    print N
    print ") = "
    print r
    print " "
    sub fin, start
    print fin
    print "s\n"
    end
.end

.namespace ["A"]

.sub fib :method
    .param pmc n
    if n >= 2 goto rec
    .return (n)
rec:
    .local pmc n1
    .local pmc n2
    .local pmc r1
    .local pmc r2
    n1 = new 'Integer'
    n2 = new 'Integer'
    n1 = n - 1
    n2 = n - 2
    r1 = self."fibA"(n1)
    r2 = self."fibB"(n2)
    n = new 'Integer'
    n = r1 + r2
    .return (n)
.end

.sub fibA :method
    .param pmc n
    if n >= 2 goto rec
    .return (n)
rec:
    .local pmc n1
    .local pmc n2
    .local pmc r1
    .local pmc r2
    n1 = new 'Integer'
    n2 = new 'Integer'
    n1 = n - 1
    n2 = n - 2
    r1 = self."fib"(n1)
    r2 = self."fibB"(n2)
    n = new 'Integer'
    n = r1 + r2
    .return (n)
.end

.namespace ["B"]

.sub fibB :method
    .param pmc n
    if n >= 2 goto rec
    .return (n)
rec:
    .local pmc n1
    .local pmc n2
    .local pmc r1
    .local pmc r2
    n1 = new 'Integer'
    n2 = new 'Integer'
    n1 = n - 1
    n2 = n - 2
    r1 = self."fib"(n1)
    r2 = self."fibA"(n2)
    n = new 'Integer'
    n = r1 + r2
    .return (n)
.end

# Local Variables:
#   mode: pir
#   fill-column: 100
# End:
# vim: expandtab shiftwidth=4 ft=pir:<commit_msg>[examples] Sped up oofib PIR benchmark by 17.81% by reducing unnecessary PMCs created in the PIR code; no changes to Parrot itself.<commit_after># Copyright (C) 2004-2009, Parrot Foundation.
# $Id$

.sub bench :main
    .param pmc argv
    .local int argc
    argc = argv
    .local pmc N
    if argc <= 1 goto noarg
    $S0 = argv[1]
    N = $S0
noarg:
    N = new 'Integer'
    N = 24
    goto begin
begin:
    .local num start
    time start

    .local pmc A
    .local pmc B
    .local pmc b

    A = newclass "A"
    B = subclass  A, "B"

    b = new "B"

    .local pmc r
    r = b."fib"(N)

    .local num fin
    time fin
    print "fib("
    print N
    print ") = "
    print r
    print " "
    sub fin, start
    print fin
    print "s\n"
    end
.end

.namespace ["A"]

.sub fib :method
    .param pmc n
    if n >= 2 goto rec
    .return (n)
rec:
    .local pmc n1
    .local pmc n2
    .local pmc r1
    .local pmc r2
    n1 = n - 1
    n2 = n - 2
    r1 = self."fibA"(n1)
    r2 = self."fibB"(n2)
    n = r1 + r2
    .return (n)
.end

.sub fibA :method
    .param pmc n
    if n >= 2 goto rec
    .return (n)
rec:
    .local pmc n1
    .local pmc n2
    .local pmc r1
    .local pmc r2
    n1 = n - 1
    n2 = n - 2
    r1 = self."fib"(n1)
    r2 = self."fibB"(n2)
    n = r1 + r2
    .return (n)
.end

.namespace ["B"]

.sub fibB :method
    .param pmc n
    if n >= 2 goto rec
    .return (n)
rec:
    .local pmc n1
    .local pmc n2
    .local pmc r1
    .local pmc r2
    n1 = n - 1
    n2 = n - 2
    r1 = self."fib"(n1)
    r2 = self."fibA"(n2)
    n = r1 + r2
    .return (n)
.end

# Local Variables:
#   mode: pir
#   fill-column: 100
# End:
# vim: expandtab shiftwidth=4 ft=pir:
{'fraction_non_alphanumeric': 0.12269585253456221, 'fraction_numerical': 0.03917050691244239, 'mean_word_length': 1.5668883961566888, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3924753', 'n_tokens_mistral': 1544, 'n_tokens_neox': 1447, 'n_words': 506}