Package: beef
Version: 1.0.1-1

The performace of the 1.0.1 version has dropped by about 98% compared
to version 0.0.6 in wheezy. It now runs far slower than a naïve implementation such as the 22 line 'microbf' program and clocks in
at around 20000 times slower than the fastest implementations.

The 0.0.6 version was already one of the slower C based interpreters
around but the version 1.0.1 performance is well below the norm and in the range normally occupied by interpreters written in intepreted
languages.

There is obviously a serious problem here.


$ echo 255 | time beef bfprog/prime.b
Primes up to: 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97 101 103 107 109 113 127 131 137 139 149 151 157 163 167 173 179 181 191 193 197 199 211 223 227 229 233 239 241 251
real    17m 16.24s
user    17m 15.87s
sys     0m 0.00s
$ echo 255 | time bf.bin/microbf bfprog/prime.b
Primes up to: 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97 101 103 107 109 113 127 131 137 139 149 151 157 163 167 173 179 181 191 193 197 199 211 223 227 229 233 239 241 251
real    0m 50.31s
user    0m 50.29s
sys     0m 0.00s
$ echo 255 | time ~/beef-0.6 bfprog/prime.b
Primes up to: 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97 101 103 107 109 113 127 131 137 139 149 151 157 163 167 173 179 181 191 193 197 199 211 223 227 229 233 239 241 251
real    0m 26.69s
user    0m 26.68s
sys     0m 0.00s
$ echo 255 | time bf.bin/deadbeef bfprog/prime.b
Primes up to: 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97 101 103 107 109 113 127 131 137 139 149 151 157 163 167 173 179 181 191 193 197 199 211 223 227 229 233 239 241 251
real    0m 11.30s
user    0m 11.29s
sys     0m 0.00s
$ echo 255 | time bf.bin/bfi bfprog/prime.b
Primes up to: 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97 101 103 107 109 113 127 131 137 139 149 151 157 163 167 173 179 181 191 193 197 199 211 223 227 229 233 239 241 251
real    0m 0.04s
user    0m 0.04s
sys     0m 0.00s
$

Microbf.c ...

#define _POSIX_C_SOURCE 200809L
#include <stdio.h>
int main (int argc, char *argv[]) {
    char *b=0, *p, t[65536]={0};
    unsigned short m=0;
    int i=0;
    FILE *fp=argc>1?fopen(argv[1], "r"):stdin;
    size_t r=0;
    if(!fp || getdelim(&b,&r,argc>1?'\0':'!',fp)<0)
        perror(argv[1]);
    else if(b&&r>0)for(p=b;*p;p++)switch(*p) {
        case '>': m++;break;
        case '<': m--;break;
        case '+': t[m]++;break;
        case '-': t[m]--;break;
        case '.': putchar(t[m]);break;
        case ',': {int c=getchar();if(c!=EOF)t[m]=c;}break;
        case '[': if(t[m]==0)while((i+=(*p=='[')-(*p==']'))&&p[1])p++;break;
        case ']': if(t[m]!=0)while((i+=(*p==']')-(*p=='['))&&p>b)p--;break;
    }
    return 0;
}


--
Rob.                          (Robert de Bath <robert$ @ debath.co.uk>)
                                             <http://www.debath.co.uk/>

Reply via email to