Import asm.js microbenchmarks and a quick harness.

This commit is contained in:
David Anderson 2013-05-03 17:14:36 -07:00
Родитель 13b325332a
Коммит 8b08dcf966
18 изменённых файлов: 20281 добавлений и 0 удалений

Просмотреть файл

@ -0,0 +1,51 @@
#include<stdio.h>
struct vec {
int x, y, z;
int r, g, b;
vec(int x_, int y_, int z_, int r_, int g_, int b_) : x(x_), y(y_), z(z_), r(r_), g(g_), b(b_) {}
static vec add(vec a, vec b) {
return vec(a.x+b.x, a.y+b.y, a.z+b.z, a.r+b.r, a.g+b.g, a.b+b.b);
}
void norm() {
x %= 1024;
y %= 1024;
z %= 1024;
r %= 1024;
b %= 1024;
g %= 1024;
}
int sum() { return x + y + z + r + g + b; }
};
int main(int argc, char **argv) {
int arg = argc > 1 ? argv[1][0] - '0' : 3;
switch(arg) {
case 0: return 0; break;
case 1: arg = 75; break;
case 2: arg = 625; break;
case 3: arg = 1250; break;
case 4: arg = 5*1250; break;
case 5: arg = 10*1250; break;
default: printf("error: %d\\n", arg); return -1;
}
int total = 0;
for (int i = 0; i < arg; i++) {
for (int j = 0; j < 50000; j++) {
vec c(i, i+i%10, j*2, i%255, j%120, i%15);
vec d(j+i%10, j*2, j%255, i%120, j%15, j);
vec e = c;
c.norm();
d.norm();
vec f = vec::add(c, d);
f = vec::add(e, f);
f.norm();
f = vec::add(d, f);
total += f.sum() % 100;
total %= 10240;
}
}
printf("sum:%d\n", total);
return 0;
}

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -0,0 +1,30 @@
#include<stdio.h>
#include<math.h>
int main(int argc, char **argv) {
int N, M;
int arg = argc > 1 ? argv[1][0] - '0' : 3;
switch(arg) {
case 0: return 0; break;
case 1: N = 20000; M = 550; break;
case 2: N = 20000; M = 3500; break;
case 3: N = 20000; M = 7000; break;
case 4: N = 20000; M = 5*7000; break;
case 5: N = 20000; M = 10*7000; break;
default: printf("error: %d\\n", arg); return -1;
}
unsigned int f = 0;
unsigned short s = 0;
for (int t = 0; t < M; t++) {
for (int i = 0; i < N; i++) {
f += i / ((t % 5)+1);
if (f > 1000) f /= (t % 3)+1;
if (i % 4 == 0) f += i * (i % 8 == 0 ? 1 : -1);
s += (short(f)*short(f)) % 256;
}
}
printf("final: %d:%d.\n", f, s);
return 0;
}

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -0,0 +1,171 @@
/*
* The Computer Language Benchmarks Game
* http://shootout.alioth.debian.org/
*
* Contributed by Eckehard Berns
* Based on code by Heiner Marxen
* and the ATS version by Hongwei Xi
*
* Modified for emscripten by azakai
*/
#include <stdlib.h>
#include <stdio.h>
struct worker_args {
int i, n;
struct worker_args *next;
};
int
fannkuch_worker(void *_arg)
{
struct worker_args *args = (worker_args*)_arg;
int *perm1, *count, *perm;
int maxflips, flips, i, n, r, j, k, tmp;
maxflips = 0;
n = args->n;
perm1 = (int*)malloc(n * sizeof(int));
perm = (int*)malloc(n * sizeof(int));
count = (int*)malloc(n * sizeof(int));
for (i = 0; i < n; i++)
perm1[i] = i;
perm1[args->i] = n - 1;
perm1[n - 1] = args->i;
r = n;
for (;;) {
for (; r > 1; r--)
count[r - 1] = r;
if (perm1[0] != 0 && perm1[n - 1] != n - 1) {
for (i = 0; i < n; i++)
perm[i] = perm1[i];
flips = 0;
k = perm[0];
do {
for (i = 1, j = k - 1; i < j; i++, j--) {
tmp = perm[i];
perm[i] = perm[j];
perm[j] = tmp;
}
flips++;
tmp = perm[k];
perm[k] = k;
k = tmp;
} while (k);
if (maxflips < flips)
maxflips = flips;
}
for (;;) {
if (r >= n - 1) {
free(perm1);
free(perm);
free(count);
return maxflips;
}
{
int p0 = perm1[0];
for (i = 0; i < r; i++)
perm1[i] = perm1[i + 1];
perm1[i] = p0;
}
if (--count[r] > 0)
break;
r++;
}
}
}
static int
fannkuch(int n)
{
struct worker_args *args, *targs;
int showmax = 30;
int *perm1, *count, i, r, maxflips, flips;
args = NULL;
for (i = 0; i < n - 1; i++) {
targs = (worker_args*)malloc(sizeof(struct worker_args));
targs->i = i;
targs->n = n;
targs->next = args;
args = targs;
}
perm1 = (int*)malloc(n * sizeof(int));
count = (int*)malloc(n * sizeof(int));
for (i = 0; i < n; i++)
perm1[i] = i;
r = n;
for (;;) {
if (showmax) {
// for (i = 0; i < n; i++)
// printf("%d", perm1[i] + 1);
// printf("\n");
showmax--;
} else
goto cleanup;
for (; r > 1; r--)
count[r - 1] = r;
for (;;) {
if (r == n)
goto cleanup;
{
int p0 = perm1[0];
for (i = 0; i < r; i++)
perm1[i] = perm1[i + 1];
perm1[i] = p0;
}
if (--count[r] > 0)
break;
r++;
}
}
cleanup:
free(perm1);
free(count);
maxflips = 0;
while (args != NULL) {
flips = (int)fannkuch_worker(args);
if (maxflips < flips)
maxflips = flips;
targs = args;
args = args->next;
free(targs);
}
return maxflips;
}
int
main(int argc, char **argv)
{
int n;
int arg = argc > 1 ? argv[1][0] - '0' : 3;
switch(arg) {
case 0: return 0; break;
case 1: n = 9; break;
case 2: n = 10; break;
case 3: n = 11; break;
case 4: n = 11; break;
case 5: n = 12; break;
default: printf("error: %d\n", arg); return -1;
}
if (n < 1) {
printf("Wrong argument.\n");
return 1;
}
printf("Pfannkuchen(%d) = %d.\n", n, fannkuch(n));
return 0;
}

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Просмотреть файл

@ -0,0 +1,210 @@
/* The Computer Language Benchmarks Game
http://shootout.alioth.debian.org/
contributed by Andrew Moon
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
// limit output, so we do not benchmark speed of printing
void puts_limited(char *x)
{
static int left = 550;
int len = strlen(x);
if (len <= left) {
//puts(x);
left -= len;
return;
}
if (left > 0) {
x[left] = '\0';
//puts(x);
x[left] = 'z';
left = 0;
}
}
struct Random {
enum { IM = 139968, IA = 3877, IC = 29573 };
Random() : last(42) {}
float get( float max = 1.0f ) {
last = ( last * IA + IC ) % IM;
return max * last / IM;
}
protected:
unsigned int last;
} rng;
struct IUB {
int c;
float p;
unsigned int pi;
};
struct Cumulative {
enum { slots = 512, };
Cumulative( IUB *start ) {
float p = 0;
for ( IUB *iter = start; iter->c; ++iter ) {
p += iter->p;
iter->p = p < 1.0 ? p : 1.0;
iter->pi = (unsigned int )( iter->p * slots );
}
for ( unsigned int i = 0; i <= slots; i++ ) {
while ( i > start->pi && start->pi != 0) {
++start;
}
table[i] = start;
}
}
const char operator[] ( float pct ) const {
IUB *iter = table[(unsigned int )( pct * slots )];
while ( iter->p < pct )
++iter;
return iter->c;
}
protected:
IUB *table[slots + 1];
};
static const size_t lineLength = 60;
struct LineBuffer {
LineBuffer() : lastN(0) {}
LineBuffer &genrand( Cumulative &table, size_t N ) {
//assert(N <= lineLength);
for ( size_t i = 0; i < N; i++ )
buffer[i] = table[rng.get()];
buffer[N] = '\n';
buffer[N+1] = '\0';
lastN = N + 1;
return *this;
}
void writeline() { puts_limited(buffer); }
protected:
char buffer[lineLength + 2];
size_t lastN;
};
struct RotatingString {
RotatingString( const char *in ) : pos(0) {
size = strlen( in );
buffer = new char[size + lineLength];
memcpy( buffer, in, size );
memcpy( buffer + size, in, lineLength );
}
~RotatingString() { delete[] buffer; }
void write( size_t bytes ) {
char* temp = new char[bytes+2];
memcpy(temp, buffer + pos, bytes);
temp[bytes] = '\n';
temp[bytes] = '\0';
puts_limited(temp);
delete temp;
pos += bytes;
if ( pos > size )
pos -= size;
}
protected:
char *buffer;
size_t size, pos;
};
template< class Output >
void makeFasta( const char *id, const char *desc, size_t N, Output &output ) {
while ( N ) {
const size_t bytes = N < lineLength ? N : lineLength;
output.writeline( bytes );
N -= bytes;
}
}
struct Repeater {
Repeater( const char *alu ) : rot(alu) {}
void writeline( size_t bytes ) { rot.write( bytes ); }
void run( const char *id, const char *desc, size_t N ) {
makeFasta( id, desc, N, *this );
}
protected:
RotatingString rot;
};
struct Randomized {
Randomized( IUB *start ) : table(start) {}
void writeline( size_t bytes ) { line.genrand(table, bytes).writeline(); }
void run( const char *id, const char *desc, size_t N ) {
makeFasta( id, desc, N, *this );
}
protected:
Cumulative table;
LineBuffer line;
};
IUB iub[] = {
{ 'a', 0.27, 0 },
{ 'c', 0.12, 0 },
{ 'g', 0.12, 0 },
{ 't', 0.27, 0 },
{ 'B', 0.02, 0 },
{ 'D', 0.02, 0 },
{ 'H', 0.02, 0 },
{ 'K', 0.02, 0 },
{ 'M', 0.02, 0 },
{ 'N', 0.02, 0 },
{ 'R', 0.02, 0 },
{ 'S', 0.02, 0 },
{ 'V', 0.02, 0 },
{ 'W', 0.02, 0 },
{ 'Y', 0.02, 0 },
{ 0, 0, 0 },
};
IUB homosapiens[] = {
{ 'a', 0.3029549426680, 0 },
{ 'c', 0.1979883004921, 0 },
{ 'g', 0.1975473066391, 0 },
{ 't', 0.3015094502008, 0 },
{ 0, 0, 0 },
};
static const char alu[] =
"GGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTG"
"GGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGA"
"GACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAA"
"AATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAAT"
"CCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAAC"
"CCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTG"
"CACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAA";
int main( int argc, const char *argv[] ) {
int n;
int arg = argc > 1 ? argv[1][0] - '0' : 3;
switch(arg) {
case 0: return 0; break;
case 1: n = 19000000/20; break;
case 2: n = 19000000/2; break;
case 3: n = 19000000; break;
case 4: n = 19000000*5; break;
case 5: n = 19000000*10; break;
default: printf("error: %d\n", arg); return -1;
}
Repeater(alu)
.run( "ONE", "Homo sapiens alu", n*2 );
Randomized(iub)
.run( "TWO", "IUB ambiguity codes", n*3 );
Randomized(homosapiens)
.run( "THREE", "Homo sapiens frequency", n*5 );
return 0;
}

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Просмотреть файл

@ -0,0 +1,84 @@
#!/usr/bin/python
# vim: set ts=4 sw=4 tw=99 et:
import os
import sys
import subprocess
from optparse import OptionParser
Benchmarks = ['copy',
'corrections',
'fannkuch',
'fasta',
'life',
'memops',
'primes',
'skinning']
RunFactor = '4'
def BuildNative(options, args, benchmark):
try:
os.remove('run-' + benchmark)
except:
pass
if os.path.isfile(benchmark + '.cpp'):
argv = [options.cxx, benchmark + '.cpp']
else:
argv = [options.cc, benchmark + '.c', '-std=gnu99']
if options.native == 'x86':
argv.extend(['-m32'])
elif options.native == 'x64':
argv.extend(['-m64'])
argv.extend(['-O2', '-o', 'run-' + benchmark + '.' + options.native])
subprocess.check_call(argv)
def BenchmarkNative(options, args):
for benchmark in Benchmarks:
BuildNative(options, args, benchmark)
for benchmark in Benchmarks:
with open('/dev/null', 'w') as fp:
before = os.times()[4]
subprocess.check_call(['./run-' + benchmark + '.' + options.native, RunFactor], stdout=fp)
after = os.times()[4]
print(benchmark + ' - ' + str(after - before))
def Exec(vec):
o = subprocess.check_output(vec, stderr=subprocess.STDOUT)
return o.decode("utf-8")
def BenchmarkJavaScript(options, args):
for benchmark in Benchmarks:
# Don't overwrite args!
argv = [] + args
argv.extend(['ubench.js', '--', benchmark + '.js', RunFactor])
t = Exec(argv)
t = t.strip()
print(benchmark + ' - ' + t)
def main(argv):
parser = OptionParser()
parser.add_option('--native', type='string', dest='native')
parser.add_option('--cc', type='string', dest='cc', default='cc')
parser.add_option('--cxx', type='string', dest='cxx', default='c++')
(options, args) = parser.parse_args(argv)
args = args[1:]
if len(args) < 1 and not options.native:
print("Usage: <shell> [-- options] or --native=x86|x64 [--cc,--cxx]")
return sys.exit(1)
if options.native:
BenchmarkNative(options, args)
else:
BenchmarkJavaScript(options, args)
if __name__ == "__main__":
main(sys.argv)

Просмотреть файл

@ -0,0 +1,96 @@
// From http://rosettacode.org/wiki/Conway%27s_Game_of_Life#C
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#define for_x for (int x = 0; x < w; x++)
#define for_y for (int y = 0; y < h; y++)
#define for_xy for_x for_y
void show(void *u, int w, int h)
{
int (*univ)[w] = u;
for_x printf("-"); printf("\n");
for_y {
for_x printf(univ[y][x] ? "[]" : " ");
printf("\n");
}
for_x printf("-"); printf("\n");
fflush(stdout);
}
void evolve(void *u, int w, int h)
{
unsigned (*univ)[w] = u;
unsigned new[h][w];
for_y for_x {
int n = 0;
for (int y1 = y - 1; y1 <= y + 1; y1++)
for (int x1 = x - 1; x1 <= x + 1; x1++)
if (univ[(y1 + h) % h][(x1 + w) % w])
n++;
if (univ[y][x]) n--;
new[y][x] = (n == 3 || (n == 2 && univ[y][x]));
}
for_y for_x univ[y][x] = new[y][x];
}
void nudge(void *u, int w, int h)
{
unsigned (*univ)[w] = u;
int sum = 0;
for_xy sum += univ[y][x];
while (sum < (w*h)/8) {
int x = sum & (w-1);
int y = (sum*sum) & (h-1);
univ[y][x] = 1;
sum++;
}
}
void game(int w, int h, int i)
{
unsigned univ[h][w];
//for_xy univ[y][x] = rand() < RAND_MAX / 10 ? 1 : 0;
int acc = 0; // nonrandom generation, for benchmarking
for_xy {
acc += (x*17) % (y*3 + 1);
univ[y][x] = acc & 1;
}
while (i != 0) {
//show(univ, w, h);
evolve(univ, w, h);
if (i > 0) {
i--;
nudge(univ, w, h); // keep it interesting for benchmark
} else {
usleep(20000);
show(univ, w, h);
}
}
show(univ, w, h);
}
int main(int argc, char **argv)
{
int w, h, i;
int arg = argc > 1 ? argv[1][0] - '0' : 3;
switch(arg) {
case 0: return 0; break;
case 1: w = h = 32; i = 2500; break;
case 2: w = h = 32; i = 13000; break;
case 3: w = h = 32; i = 24000; break;
case 4: w = h = 32; i = 5*24000; break;
case 5: w = h = 32; i = 10*24000; break;
default: printf("error: %d\\n", arg); return -1;
}
printf("life: %d,%d,%d,%d\n", arg, w, h, i);
game(w, h, i);
return 0;
}

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -0,0 +1,30 @@
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int main(int argc, char **argv) {
int N, M;
int arg = argc > 1 ? argv[1][0] - '0' : 3;
switch(arg) {
case 0: return 0; break;
case 1: N = 1024*1024; M = 55; break;
case 2: N = 1024*1024; M = 400; break;
case 3: N = 1024*1024; M = 800; break;
case 4: N = 1024*1024; M = 4000; break;
case 5: N = 1024*1024; M = 8000; break;
default: printf("error: %d\n", arg); return -1;
}
int final = 0;
char *buf = (char*)malloc(N);
for (int t = 0; t < M; t++) {
for (int i = 0; i < N; i++)
buf[i] = (i + final)%256;
for (int i = 0; i < N; i++)
final += buf[i] & 1;
final = final % 1000;
}
printf("final: %d.\n", final);
return 0;
}

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Просмотреть файл

@ -0,0 +1,33 @@
#include<stdio.h>
#include<math.h>
int main(int argc, char **argv) {
int arg = argc > 1 ? argv[1][0] - '0' : 3;
switch(arg) {
case 0: return 0; break;
case 1: arg = 33000; break;
case 2: arg = 130000; break;
case 3: arg = 220000; break;
case 4: arg = 610000; break;
case 5: arg = 1010000; break;
default: printf("error: %d\\n", arg); return -1;
}
int primes = 0, curri = 2;
while (primes < arg) {
int ok = true;
for (int j = 2; j < sqrtf(curri); j++) {
if (curri % j == 0) {
ok = false;
break;
}
}
if (ok) {
primes++;
}
curri++;
}
printf("lastprime: %d.\n", curri-1);
return 0;
}

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -0,0 +1,211 @@
// From https://github.com/chadaustin/Web-Benchmarks/blob/master/skinning_test_no_simd.cpp
// Modifications:
// 1. Run for a fixed # of iterations, so the total runtime is the benchmark
// 2. Not have so much stuff on the stack in main()
//
// compiled in cygwin with:
// g++ -Wall -O2 -o skinning_test_no_simd skinning_test_no_simd.cpp
#include <vector>
#include <set>
#include <map>
#include <assert.h>
#include <math.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
struct CalBase4 {
float x, y, z, w;
void set(float _x, float _y, float _z, float _w) {
x = _x;
y = _y;
z = _z;
w = _w;
}
};
struct CalVector4 : CalBase4 {
CalVector4() {
x = 0.0f;
y = 0.0f;
z = 0.0f;
w = 0.0f;
}
CalVector4(float x, float y, float z, float w = 0.0f) {
this->x = x;
this->y = y;
this->z = z;
this->w = w;
}
void setAsVector(float x, float y, float z) {
this->x = x;
this->y = y;
this->z = z;
w = 0.0f;
}
};
struct CalPoint4 : CalBase4 {
CalPoint4() {
x = 0.0f;
y = 0.0f;
z = 0.0f;
w = 1.0f;
}
CalPoint4(float x, float y, float z, float w = 1.0f) {
this->x = x;
this->y = y;
this->z = z;
this->w = w;
}
void setAsPoint(float x, float y, float z) {
x = this->x;
y = this->y;
z = this->z;
w = 1.0f;
}
};
// 3x3 transform matrix plus a translation 3-vector (stored in the w components
// of the rows.
struct BoneTransform {
CalVector4 rowx;
CalVector4 rowy;
CalVector4 rowz;
};
struct Influence
{
Influence() {
boneId = -1;
weight = 0.0f;
lastInfluenceForThisVertex = 0;
}
Influence(unsigned b, float w, bool last) {
boneId = b;
weight = w;
lastInfluenceForThisVertex = last ? 1 : 0;
}
unsigned boneId;
float weight;
unsigned lastInfluenceForThisVertex;
};
struct Vertex
{
CalPoint4 position;
CalVector4 normal;
};
inline void ScaleMatrix(BoneTransform& result, const BoneTransform& mat, const float s) {
result.rowx.x = s * mat.rowx.x;
result.rowx.y = s * mat.rowx.y;
result.rowx.z = s * mat.rowx.z;
result.rowx.w = s * mat.rowx.w;
result.rowy.x = s * mat.rowy.x;
result.rowy.y = s * mat.rowy.y;
result.rowy.z = s * mat.rowy.z;
result.rowy.w = s * mat.rowy.w;
result.rowz.x = s * mat.rowz.x;
result.rowz.y = s * mat.rowz.y;
result.rowz.z = s * mat.rowz.z;
result.rowz.w = s * mat.rowz.w;
}
inline void AddScaledMatrix(BoneTransform& result, const BoneTransform& mat, const float s) {
result.rowx.x += s * mat.rowx.x;
result.rowx.y += s * mat.rowx.y;
result.rowx.z += s * mat.rowx.z;
result.rowx.w += s * mat.rowx.w;
result.rowy.x += s * mat.rowy.x;
result.rowy.y += s * mat.rowy.y;
result.rowy.z += s * mat.rowy.z;
result.rowy.w += s * mat.rowy.w;
result.rowz.x += s * mat.rowz.x;
result.rowz.y += s * mat.rowz.y;
result.rowz.z += s * mat.rowz.z;
result.rowz.w += s * mat.rowz.w;
}
inline void TransformPoint(CalVector4& result, const BoneTransform& m, const CalBase4& v) {
result.x = m.rowx.x * v.x + m.rowx.y * v.y + m.rowx.z * v.z + m.rowx.w;
result.y = m.rowy.x * v.x + m.rowy.y * v.y + m.rowy.z * v.z + m.rowy.w;
result.z = m.rowz.x * v.x + m.rowz.y * v.y + m.rowz.z * v.z + m.rowz.w;
}
inline void TransformVector(CalVector4& result, const BoneTransform& m, const CalBase4& v) {
result.x = m.rowx.x * v.x + m.rowx.y * v.y + m.rowx.z * v.z;
result.y = m.rowy.x * v.x + m.rowy.y * v.y + m.rowy.z * v.z;
result.z = m.rowz.x * v.x + m.rowz.y * v.y + m.rowz.z * v.z;
}
void calculateVerticesAndNormals_x87(
const BoneTransform* boneTransforms,
int vertexCount,
const Vertex* vertices,
const Influence* influences,
CalVector4* output_vertex
) {
BoneTransform total_transform;
// calculate all submesh vertices
while (vertexCount--) {
ScaleMatrix(total_transform, boneTransforms[influences->boneId], influences->weight);
while (!influences++->lastInfluenceForThisVertex) {
AddScaledMatrix(total_transform, boneTransforms[influences->boneId], influences->weight);
}
TransformPoint(output_vertex[0], total_transform, vertices->position);
TransformVector(output_vertex[1], total_transform, vertices->normal);
++vertices;
output_vertex += 2;
}
}
int main (int argc, char*argv[])
{
int N, M;
int arg = argc > 1 ? argv[1][0] - '0' : 3;
switch(arg) {
case 0: return 0; break;
case 1: N = 2000; M = 1700; break;
case 2: N = 6600; M = 6500; break;
case 3: N = 9500; M = 10000; break;
case 4: N = 2*11000; M = 2*12000; break;
case 5: N = 3*10000; M = 3*10800; break;
default: printf("error: %d\\n", arg); return -1;
}
Vertex *v = new Vertex[N];
Influence *i = new Influence[N];
for (int k = 0; k < N; ++k) {
v[k].position.setAsPoint(1.0f, 2.0f, 3.0f);
v[k].normal.setAsVector(0.0f, 0.0f, 1.0f);
i[k].boneId = 0;
i[k].weight = 1.0f;
i[k].lastInfluenceForThisVertex = true;
}
BoneTransform bt;
memset(&bt, 0, sizeof(bt));
CalVector4 *output = new CalVector4[N * 2];
for (unsigned j = 0; j < M; j++)
calculateVerticesAndNormals_x87(&bt, N, v, i, output);
float sum = 0;
for (unsigned j = 0; j < N * 2; ++j) {
sum += (output[j].x + output[j].y + output[j].z + output[j].w);
}
printf("blah=%f\n", sum);
}

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Просмотреть файл

@ -0,0 +1,36 @@
// vim: set ts=2 sw=2 tw=99 et:
var __BENCHMARK__;
var __ARGV__ = (function (argv) {
var i = 0;
if (argv[i] == '--')
i++;
if (argv.length > i)
__BENCHMARK__ = argv[i++];
return argv.slice(i, argv.length);
})(arguments);
var scriptArgs = __ARGV__;
var arguments = __ARGV__;
function RunBenchmark(file)
{
var begin = Date.now();
load(file);
return Date.now() - begin;
}
function main(argv)
{
if (!__BENCHMARK__) {
print('No file given!');
return quit();
}
var file = __BENCHMARK__.replace('.js', '');
print(RunBenchmark(file + '.js'));
}
main(arguments);