Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
.Stringy as a mostly-synonym for .Str
  • Loading branch information
sorear committed Jun 7, 2011
1 parent 47239f7 commit c757e63
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 10 deletions.
7 changes: 6 additions & 1 deletion lib/CORE.setting
Expand Up @@ -23,6 +23,7 @@ my class Mu {
$tn ~ "()"
}
}
method Stringy() { defined(self) ?? self.Str !! "" }
method succ() { defined(self) ?? die("cannot increment a value of type {self.typename()}") !! 1 }
method pred() { defined(self) ?? die("cannot decrement a value of type {self.typename()}") !! -1 }
method notdef() { !defined(self) }
Expand Down Expand Up @@ -951,9 +952,13 @@ my class Junction is Mu {
my @kinds = <all none one any>;
method perl() {
@kinds[self!kind] ~ "(" ~ join(", ", map *.perl, @$!eigenstates) ~ ")"
defined(self) ?? (@kinds[self!kind] ~ "(" ~
join(", ", map *.perl, @$!eigenstates) ~ ")") !! "Junction"
}
method Str() { self.perl }
method Stringy() { self.FALLBACK("Stringy") }
method from-parcel(Int $kind, Mu $pcl) {
self!create($kind, $pcl)
}
Expand Down
24 changes: 15 additions & 9 deletions perf/std-20110528.pl6
Expand Up @@ -16,15 +16,21 @@ sub bench($name, $nr, $f) {
say "$name = {($time - $avg)*1e6}µs [{$time*$nr}s / $nr]";
}

my @arr;
my class CEmpty {
}

my Mu $j = any(1..5);
my class CAttrs {
has $.x;
has $.y;
has $.z;
};

sub onlysub($x) { $x }
my %h = (1 => True, 2 => True, 3 => True, 4 => True, 5 => True);
my %h2 = (:a, :b, :c, :d, :e);
my class CAttrInits {
has $.x = 1;
has $.y = 2;
has $.z = 3;
}

bench '|||', 1000000, sub () { 1|2|3|4|5 };
#bench 'any(..)', 10000, sub () { any(1..5) };
bench 'onlysub($j)', 100000, sub () { onlysub($j) };
bench '$j.abs', 100000, sub () { $j.abs };
bench "CEmpty.new", 1000000, sub () { CEmpty.new };
bench "CAttrs.new", 1000000, sub () { CAttrs.new };
bench "CAttrInits.new", 100000, sub () { CAttrInits.new };

0 comments on commit c757e63

Please sign in to comment.