too many changes to list
This commit is contained in:
parent
916c25f9a7
commit
07d5a8085b
200 changed files with 24344 additions and 17809 deletions
|
|
@ -1,296 +0,0 @@
|
|||
// This is adapted from a benchmark written by John Ellis and Pete Kovac
|
||||
// of Post Communications.
|
||||
// It was modified by Hans Boehm of Silicon Graphics.
|
||||
// Translated to C++ 30 May 1997 by William D Clinger of Northeastern Univ.
|
||||
// Translated to C 15 March 2000 by Hans Boehm, now at HP Labs.
|
||||
//
|
||||
// This is no substitute for real applications. No actual application
|
||||
// is likely to behave in exactly this way. However, this benchmark was
|
||||
// designed to be more representative of real applications than other
|
||||
// Java GC benchmarks of which we are aware.
|
||||
// It attempts to model those properties of allocation requests that
|
||||
// are important to current GC techniques.
|
||||
// It is designed to be used either to obtain a single overall performance
|
||||
// number, or to give a more detailed estimate of how collector
|
||||
// performance varies with object lifetimes. It prints the time
|
||||
// required to allocate and collect balanced binary trees of various
|
||||
// sizes. Smaller trees result in shorter object lifetimes. Each cycle
|
||||
// allocates roughly the same amount of memory.
|
||||
// Two data structures are kept around during the entire process, so
|
||||
// that the measured performance is representative of applications
|
||||
// that maintain some live in-memory data. One of these is a tree
|
||||
// containing many pointers. The other is a large array containing
|
||||
// double precision floating point numbers. Both should be of comparable
|
||||
// size.
|
||||
//
|
||||
// The results are only really meaningful together with a specification
|
||||
// of how much memory was used. It is possible to trade memory for
|
||||
// better time performance. This benchmark should be run in a 32 MB
|
||||
// heap, though we don't currently know how to enforce that uniformly.
|
||||
//
|
||||
// Unlike the original Ellis and Kovac benchmark, we do not attempt
|
||||
// measure pause times. This facility should eventually be added back
|
||||
// in. There are several reasons for omitting it for now. The original
|
||||
// implementation depended on assumptions about the thread scheduler
|
||||
// that don't hold uniformly. The results really measure both the
|
||||
// scheduler and GC. Pause time measurements tend to not fit well with
|
||||
// current benchmark suites. As far as we know, none of the current
|
||||
// commercial Java implementations seriously attempt to minimize GC pause
|
||||
// times.
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
#ifdef GC
|
||||
# include "gc.h"
|
||||
#endif
|
||||
|
||||
#ifdef PROFIL
|
||||
extern void init_profiling();
|
||||
extern dump_profile();
|
||||
#endif
|
||||
|
||||
// These macros were a quick hack for the Macintosh.
|
||||
//
|
||||
// #define currentTime() clock()
|
||||
// #define elapsedTime(x) ((1000*(x))/CLOCKS_PER_SEC)
|
||||
|
||||
#define currentTime() stats_rtclock()
|
||||
#define elapsedTime(x) (x)
|
||||
|
||||
/* Get the current time in milliseconds */
|
||||
|
||||
unsigned
|
||||
stats_rtclock( void )
|
||||
{
|
||||
struct timeval t;
|
||||
struct timezone tz;
|
||||
|
||||
if (gettimeofday( &t, &tz ) == -1)
|
||||
return 0;
|
||||
return (t.tv_sec * 1000 + t.tv_usec / 1000);
|
||||
}
|
||||
|
||||
static const int kStretchTreeDepth = 18; // about 16Mb
|
||||
static const int kLongLivedTreeDepth = 16; // about 4Mb
|
||||
static const int kArraySize = 500000; // about 4Mb
|
||||
static const int kMinTreeDepth = 4;
|
||||
static const int kMaxTreeDepth = 16;
|
||||
|
||||
typedef struct Node0_struct {
|
||||
struct Node0_struct * left;
|
||||
struct Node0_struct * right;
|
||||
int i, j;
|
||||
} Node0;
|
||||
|
||||
#ifdef HOLES
|
||||
# define HOLE() GC_NEW(Node0);
|
||||
#else
|
||||
# define HOLE()
|
||||
#endif
|
||||
|
||||
typedef Node0 *Node;
|
||||
|
||||
void init_Node(Node me, Node l, Node r) {
|
||||
me -> left = l;
|
||||
me -> right = r;
|
||||
}
|
||||
|
||||
#ifndef GC
|
||||
void destroy_Node(Node me) {
|
||||
if (me -> left) {
|
||||
destroy_Node(me -> left);
|
||||
}
|
||||
if (me -> right) {
|
||||
destroy_Node(me -> right);
|
||||
}
|
||||
free(me);
|
||||
}
|
||||
#endif
|
||||
|
||||
// Nodes used by a tree of a given size
|
||||
static int TreeSize(int i) {
|
||||
return ((1 << (i + 1)) - 1);
|
||||
}
|
||||
|
||||
// Number of iterations to use for a given tree depth
|
||||
static int NumIters(int i) {
|
||||
return 2 * TreeSize(kStretchTreeDepth) / TreeSize(i);
|
||||
}
|
||||
|
||||
// Build tree top down, assigning to older objects.
|
||||
static void Populate(int iDepth, Node thisNode) {
|
||||
if (iDepth<=0) {
|
||||
return;
|
||||
} else {
|
||||
iDepth--;
|
||||
# ifdef GC
|
||||
thisNode->left = GC_NEW(Node0); HOLE();
|
||||
thisNode->right = GC_NEW(Node0); HOLE();
|
||||
# else
|
||||
thisNode->left = calloc(1, sizeof(Node0));
|
||||
thisNode->right = calloc(1, sizeof(Node0));
|
||||
# endif
|
||||
Populate (iDepth, thisNode->left);
|
||||
Populate (iDepth, thisNode->right);
|
||||
}
|
||||
}
|
||||
|
||||
// Build tree bottom-up
|
||||
static Node MakeTree(int iDepth) {
|
||||
Node result;
|
||||
if (iDepth<=0) {
|
||||
# ifndef GC
|
||||
result = calloc(1, sizeof(Node0));
|
||||
# else
|
||||
result = GC_NEW(Node0); HOLE();
|
||||
# endif
|
||||
/* result is implicitly initialized in both cases. */
|
||||
return result;
|
||||
} else {
|
||||
Node left = MakeTree(iDepth-1);
|
||||
Node right = MakeTree(iDepth-1);
|
||||
# ifndef GC
|
||||
result = malloc(sizeof(Node0));
|
||||
# else
|
||||
result = GC_NEW(Node0); HOLE();
|
||||
# endif
|
||||
init_Node(result, left, right);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
static void PrintDiagnostics() {
|
||||
#if 0
|
||||
long lFreeMemory = Runtime.getRuntime().freeMemory();
|
||||
long lTotalMemory = Runtime.getRuntime().totalMemory();
|
||||
|
||||
System.out.print(" Total memory available="
|
||||
+ lTotalMemory + " bytes");
|
||||
System.out.println(" Free memory=" + lFreeMemory + " bytes");
|
||||
#endif
|
||||
}
|
||||
|
||||
static void TimeConstruction(int depth) {
|
||||
long tStart, tFinish;
|
||||
int iNumIters = NumIters(depth);
|
||||
Node tempTree;
|
||||
int i;
|
||||
|
||||
printf("Creating %d trees of depth %d\n", iNumIters, depth);
|
||||
|
||||
tStart = currentTime();
|
||||
for (i = 0; i < iNumIters; ++i) {
|
||||
# ifndef GC
|
||||
tempTree = calloc(1, sizeof(Node0));
|
||||
# else
|
||||
tempTree = GC_NEW(Node0);
|
||||
# endif
|
||||
Populate(depth, tempTree);
|
||||
# ifndef GC
|
||||
destroy_Node(tempTree);
|
||||
# endif
|
||||
tempTree = 0;
|
||||
}
|
||||
tFinish = currentTime();
|
||||
printf("\tTop down construction took %d msec\n",
|
||||
elapsedTime(tFinish - tStart));
|
||||
|
||||
tStart = currentTime();
|
||||
for (i = 0; i < iNumIters; ++i) {
|
||||
tempTree = MakeTree(depth);
|
||||
# ifndef GC
|
||||
destroy_Node(tempTree);
|
||||
# endif
|
||||
tempTree = 0;
|
||||
}
|
||||
tFinish = currentTime();
|
||||
printf("\tBottom up construction took %d msec\n",
|
||||
elapsedTime(tFinish - tStart));
|
||||
|
||||
}
|
||||
|
||||
int main() {
|
||||
Node root;
|
||||
Node longLivedTree;
|
||||
Node tempTree;
|
||||
long tStart, tFinish;
|
||||
long tElapsed;
|
||||
int i, d;
|
||||
double *array;
|
||||
|
||||
#ifdef GC
|
||||
// GC_full_freq = 30;
|
||||
// GC_free_space_divisor = 16;
|
||||
// GC_enable_incremental();
|
||||
#endif
|
||||
printf("Garbage Collector Test\n");
|
||||
printf(" Live storage will peak at %d bytes.\n\n",
|
||||
2 * sizeof(Node0) * TreeSize(kLongLivedTreeDepth) +
|
||||
sizeof(double) * kArraySize);
|
||||
printf(" Stretching memory with a binary tree of depth %d\n",
|
||||
kStretchTreeDepth);
|
||||
PrintDiagnostics();
|
||||
# ifdef PROFIL
|
||||
init_profiling();
|
||||
# endif
|
||||
|
||||
tStart = currentTime();
|
||||
|
||||
// Stretch the memory space quickly
|
||||
tempTree = MakeTree(kStretchTreeDepth);
|
||||
# ifndef GC
|
||||
destroy_Node(tempTree);
|
||||
# endif
|
||||
tempTree = 0;
|
||||
|
||||
// Create a long lived object
|
||||
printf(" Creating a long-lived binary tree of depth %d\n",
|
||||
kLongLivedTreeDepth);
|
||||
# ifndef GC
|
||||
longLivedTree = calloc(1, sizeof(Node0));
|
||||
# else
|
||||
longLivedTree = GC_NEW(Node0);
|
||||
# endif
|
||||
Populate(kLongLivedTreeDepth, longLivedTree);
|
||||
|
||||
// Create long-lived array, filling half of it
|
||||
printf(" Creating a long-lived array of %d doubles\n", kArraySize);
|
||||
# ifndef GC
|
||||
array = malloc(kArraySize * sizeof(double));
|
||||
# else
|
||||
# ifndef NO_PTRFREE
|
||||
array = GC_MALLOC_ATOMIC(sizeof(double) * kArraySize);
|
||||
# else
|
||||
array = GC_MALLOC(sizeof(double) * kArraySize);
|
||||
# endif
|
||||
# endif
|
||||
for (i = 0; i < kArraySize/2; ++i) {
|
||||
array[i] = 1.0/i;
|
||||
}
|
||||
PrintDiagnostics();
|
||||
|
||||
for (d = kMinTreeDepth; d <= kMaxTreeDepth; d += 2) {
|
||||
TimeConstruction(d);
|
||||
}
|
||||
|
||||
if (longLivedTree == 0 || array[1000] != 1.0/1000)
|
||||
fprintf(stderr, "Failed\n");
|
||||
// fake reference to LongLivedTree
|
||||
// and array
|
||||
// to keep them from being optimized away
|
||||
|
||||
tFinish = currentTime();
|
||||
tElapsed = elapsedTime(tFinish-tStart);
|
||||
PrintDiagnostics();
|
||||
printf("Completed in %d msec\n", tElapsed);
|
||||
# ifdef GC
|
||||
printf("Completed %d collections\n", GC_gc_no);
|
||||
printf("Heap size is %d\n", GC_get_heap_size());
|
||||
# endif
|
||||
# ifdef PROFIL
|
||||
dump_profile();
|
||||
# endif
|
||||
}
|
||||
|
||||
|
|
@ -1,266 +0,0 @@
|
|||
// This is adapted from a benchmark written by John Ellis and Pete Kovac
|
||||
// of Post Communications.
|
||||
// It was modified by Hans Boehm of Silicon Graphics.
|
||||
// Translated to C++ 30 May 1997 by William D Clinger of Northeastern Univ.
|
||||
//
|
||||
// This is no substitute for real applications. No actual application
|
||||
// is likely to behave in exactly this way. However, this benchmark was
|
||||
// designed to be more representative of real applications than other
|
||||
// Java GC benchmarks of which we are aware.
|
||||
// It attempts to model those properties of allocation requests that
|
||||
// are important to current GC techniques.
|
||||
// It is designed to be used either to obtain a single overall performance
|
||||
// number, or to give a more detailed estimate of how collector
|
||||
// performance varies with object lifetimes. It prints the time
|
||||
// required to allocate and collect balanced binary trees of various
|
||||
// sizes. Smaller trees result in shorter object lifetimes. Each cycle
|
||||
// allocates roughly the same amount of memory.
|
||||
// Two data structures are kept around during the entire process, so
|
||||
// that the measured performance is representative of applications
|
||||
// that maintain some live in-memory data. One of these is a tree
|
||||
// containing many pointers. The other is a large array containing
|
||||
// double precision floating point numbers. Both should be of comparable
|
||||
// size.
|
||||
//
|
||||
// The results are only really meaningful together with a specification
|
||||
// of how much memory was used. It is possible to trade memory for
|
||||
// better time performance. This benchmark should be run in a 32 MB
|
||||
// heap, though we don't currently know how to enforce that uniformly.
|
||||
//
|
||||
// Unlike the original Ellis and Kovac benchmark, we do not attempt
|
||||
// measure pause times. This facility should eventually be added back
|
||||
// in. There are several reasons for omitting it for now. The original
|
||||
// implementation depended on assumptions about the thread scheduler
|
||||
// that don't hold uniformly. The results really measure both the
|
||||
// scheduler and GC. Pause time measurements tend to not fit well with
|
||||
// current benchmark suites. As far as we know, none of the current
|
||||
// commercial Java implementations seriously attempt to minimize GC pause
|
||||
// times.
|
||||
|
||||
#include <new.h>
|
||||
#include <iostream.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
#ifdef GC
|
||||
# include "gc.h"
|
||||
#endif
|
||||
|
||||
// These macros were a quick hack for the Macintosh.
|
||||
//
|
||||
// #define currentTime() clock()
|
||||
// #define elapsedTime(x) ((1000*(x))/CLOCKS_PER_SEC)
|
||||
|
||||
#define currentTime() stats_rtclock()
|
||||
#define elapsedTime(x) (x)
|
||||
|
||||
/* Get the current time in milliseconds */
|
||||
|
||||
unsigned
|
||||
stats_rtclock( void )
|
||||
{
|
||||
struct timeval t;
|
||||
struct timezone tz;
|
||||
|
||||
if (gettimeofday( &t, &tz ) == -1)
|
||||
return 0;
|
||||
return (t.tv_sec * 1000 + t.tv_usec / 1000);
|
||||
}
|
||||
|
||||
static const int kStretchTreeDepth = 18; // about 16Mb
|
||||
static const int kLongLivedTreeDepth = 16; // about 4Mb
|
||||
static const int kArraySize = 500000; // about 4Mb
|
||||
static const int kMinTreeDepth = 4;
|
||||
static const int kMaxTreeDepth = 16;
|
||||
|
||||
typedef struct Node0 *Node;
|
||||
|
||||
struct Node0 {
|
||||
Node left;
|
||||
Node right;
|
||||
int i, j;
|
||||
Node0(Node l, Node r) { left = l; right = r; }
|
||||
Node0() { left = 0; right = 0; }
|
||||
# ifndef GC
|
||||
~Node0() { if (left) delete left; if (right) delete right; }
|
||||
# endif
|
||||
};
|
||||
|
||||
struct GCBench {
|
||||
|
||||
// Nodes used by a tree of a given size
|
||||
static int TreeSize(int i) {
|
||||
return ((1 << (i + 1)) - 1);
|
||||
}
|
||||
|
||||
// Number of iterations to use for a given tree depth
|
||||
static int NumIters(int i) {
|
||||
return 2 * TreeSize(kStretchTreeDepth) / TreeSize(i);
|
||||
}
|
||||
|
||||
// Build tree top down, assigning to older objects.
|
||||
static void Populate(int iDepth, Node thisNode) {
|
||||
if (iDepth<=0) {
|
||||
return;
|
||||
} else {
|
||||
iDepth--;
|
||||
# ifndef GC
|
||||
thisNode->left = new Node0();
|
||||
thisNode->right = new Node0();
|
||||
# else
|
||||
thisNode->left = new (GC_NEW(Node0)) Node0();
|
||||
thisNode->right = new (GC_NEW(Node0)) Node0();
|
||||
# endif
|
||||
Populate (iDepth, thisNode->left);
|
||||
Populate (iDepth, thisNode->right);
|
||||
}
|
||||
}
|
||||
|
||||
// Build tree bottom-up
|
||||
static Node MakeTree(int iDepth) {
|
||||
if (iDepth<=0) {
|
||||
# ifndef GC
|
||||
return new Node0();
|
||||
# else
|
||||
return new (GC_NEW(Node0)) Node0();
|
||||
# endif
|
||||
} else {
|
||||
# ifndef GC
|
||||
return new Node0(MakeTree(iDepth-1),
|
||||
MakeTree(iDepth-1));
|
||||
# else
|
||||
return new (GC_NEW(Node0)) Node0(MakeTree(iDepth-1),
|
||||
MakeTree(iDepth-1));
|
||||
# endif
|
||||
}
|
||||
}
|
||||
|
||||
static void PrintDiagnostics() {
|
||||
#if 0
|
||||
long lFreeMemory = Runtime.getRuntime().freeMemory();
|
||||
long lTotalMemory = Runtime.getRuntime().totalMemory();
|
||||
|
||||
System.out.print(" Total memory available="
|
||||
+ lTotalMemory + " bytes");
|
||||
System.out.println(" Free memory=" + lFreeMemory + " bytes");
|
||||
#endif
|
||||
}
|
||||
|
||||
static void TimeConstruction(int depth) {
|
||||
long tStart, tFinish;
|
||||
int iNumIters = NumIters(depth);
|
||||
Node tempTree;
|
||||
|
||||
cout << "Creating " << iNumIters
|
||||
<< " trees of depth " << depth << endl;
|
||||
|
||||
tStart = currentTime();
|
||||
for (int i = 0; i < iNumIters; ++i) {
|
||||
# ifndef GC
|
||||
tempTree = new Node0();
|
||||
# else
|
||||
tempTree = new (GC_NEW(Node0)) Node0();
|
||||
# endif
|
||||
Populate(depth, tempTree);
|
||||
# ifndef GC
|
||||
delete tempTree;
|
||||
# endif
|
||||
tempTree = 0;
|
||||
}
|
||||
tFinish = currentTime();
|
||||
cout << "\tTop down construction took "
|
||||
<< elapsedTime(tFinish - tStart) << " msec" << endl;
|
||||
|
||||
tStart = currentTime();
|
||||
for (int i = 0; i < iNumIters; ++i) {
|
||||
tempTree = MakeTree(depth);
|
||||
# ifndef GC
|
||||
delete tempTree;
|
||||
# endif
|
||||
tempTree = 0;
|
||||
}
|
||||
tFinish = currentTime();
|
||||
cout << "\tBottom up construction took "
|
||||
<< elapsedTime(tFinish - tStart) << " msec" << endl;
|
||||
|
||||
}
|
||||
|
||||
void main() {
|
||||
Node root;
|
||||
Node longLivedTree;
|
||||
Node tempTree;
|
||||
long tStart, tFinish;
|
||||
long tElapsed;
|
||||
|
||||
#ifdef GC
|
||||
// GC_full_freq = 30;
|
||||
GC_enable_incremental();
|
||||
#endif
|
||||
cout << "Garbage Collector Test" << endl;
|
||||
cout << " Live storage will peak at "
|
||||
<< 2 * sizeof(Node0) * TreeSize(kLongLivedTreeDepth) +
|
||||
sizeof(double) * kArraySize
|
||||
<< " bytes." << endl << endl;
|
||||
cout << " Stretching memory with a binary tree of depth "
|
||||
<< kStretchTreeDepth << endl;
|
||||
PrintDiagnostics();
|
||||
|
||||
tStart = currentTime();
|
||||
|
||||
// Stretch the memory space quickly
|
||||
tempTree = MakeTree(kStretchTreeDepth);
|
||||
# ifndef GC
|
||||
delete tempTree;
|
||||
# endif
|
||||
tempTree = 0;
|
||||
|
||||
// Create a long lived object
|
||||
cout << " Creating a long-lived binary tree of depth "
|
||||
<< kLongLivedTreeDepth << endl;
|
||||
# ifndef GC
|
||||
longLivedTree = new Node0();
|
||||
# else
|
||||
longLivedTree = new (GC_NEW(Node0)) Node0();
|
||||
# endif
|
||||
Populate(kLongLivedTreeDepth, longLivedTree);
|
||||
|
||||
// Create long-lived array, filling half of it
|
||||
cout << " Creating a long-lived array of "
|
||||
<< kArraySize << " doubles" << endl;
|
||||
# ifndef GC
|
||||
double *array = new double[kArraySize];
|
||||
# else
|
||||
double *array = (double *)
|
||||
GC_MALLOC_ATOMIC(sizeof(double) * kArraySize);
|
||||
# endif
|
||||
for (int i = 0; i < kArraySize/2; ++i) {
|
||||
array[i] = 1.0/i;
|
||||
}
|
||||
PrintDiagnostics();
|
||||
|
||||
for (int d = kMinTreeDepth; d <= kMaxTreeDepth; d += 2)
|
||||
{
|
||||
TimeConstruction(d);
|
||||
}
|
||||
|
||||
if (longLivedTree == 0 || array[1000] != 1.0/1000)
|
||||
cout << "Failed" << endl;
|
||||
// fake reference to LongLivedTree
|
||||
// and array
|
||||
// to keep them from being optimized away
|
||||
|
||||
tFinish = currentTime();
|
||||
tElapsed = elapsedTime(tFinish-tStart);
|
||||
PrintDiagnostics();
|
||||
cout << "Completed in " << tElapsed << " msec" << endl;
|
||||
# ifdef GC
|
||||
cout << "Completed " << GC_gc_no << " collections" <<endl;
|
||||
cout << "Heap size is " << GC_get_heap_size() << endl;
|
||||
# endif
|
||||
}
|
||||
};
|
||||
|
||||
main () {
|
||||
GCBench x;
|
||||
x.main();
|
||||
}
|
||||
|
||||
|
|
@ -1,182 +0,0 @@
|
|||
// This is adapted from a benchmark written by John Ellis and Pete Kovac
|
||||
// of Post Communications.
|
||||
// It was modified by Hans Boehm of Silicon Graphics.
|
||||
//
|
||||
// This is no substitute for real applications. No actual application
|
||||
// is likely to behave in exactly this way. However, this benchmark was
|
||||
// designed to be more representative of real applications than other
|
||||
// Java GC benchmarks of which we are aware.
|
||||
// It attempts to model those properties of allocation requests that
|
||||
// are important to current GC techniques.
|
||||
// It is designed to be used either to obtain a single overall performance
|
||||
// number, or to give a more detailed estimate of how collector
|
||||
// performance varies with object lifetimes. It prints the time
|
||||
// required to allocate and collect balanced binary trees of various
|
||||
// sizes. Smaller trees result in shorter object lifetimes. Each cycle
|
||||
// allocates roughly the same amount of memory.
|
||||
// Two data structures are kept around during the entire process, so
|
||||
// that the measured performance is representative of applications
|
||||
// that maintain some live in-memory data. One of these is a tree
|
||||
// containing many pointers. The other is a large array containing
|
||||
// double precision floating point numbers. Both should be of comparable
|
||||
// size.
|
||||
//
|
||||
// The results are only really meaningful together with a specification
|
||||
// of how much memory was used. It is possible to trade memory for
|
||||
// better time performance. This benchmark should be run in a 32 MB
|
||||
// heap, though we don't currently know how to enforce that uniformly.
|
||||
//
|
||||
// Unlike the original Ellis and Kovac benchmark, we do not attempt
|
||||
// measure pause times. This facility should eventually be added back
|
||||
// in. There are several reasons for omitting it for now. The original
|
||||
// implementation depended on assumptions about the thread scheduler
|
||||
// that don't hold uniformly. The results really measure both the
|
||||
// scheduler and GC. Pause time measurements tend to not fit well with
|
||||
// current benchmark suites. As far as we know, none of the current
|
||||
// commercial Java implementations seriously attempt to minimize GC pause
|
||||
// times.
|
||||
//
|
||||
// Known deficiencies:
|
||||
// - No way to check on memory use
|
||||
// - No cyclic data structures
|
||||
// - No attempt to measure variation with object size
|
||||
// - Results are sensitive to locking cost, but we dont
|
||||
// check for proper locking
|
||||
|
||||
class Node {
|
||||
Node left, right;
|
||||
int i, j;
|
||||
Node(Node l, Node r) { left = l; right = r; }
|
||||
Node() { }
|
||||
}
|
||||
|
||||
public class GCBench {
|
||||
|
||||
public static final int kStretchTreeDepth = 18; // about 16Mb
|
||||
public static final int kLongLivedTreeDepth = 16; // about 4Mb
|
||||
public static final int kArraySize = 500000; // about 4Mb
|
||||
public static final int kMinTreeDepth = 4;
|
||||
public static final int kMaxTreeDepth = 16;
|
||||
|
||||
// Nodes used by a tree of a given size
|
||||
static int TreeSize(int i) {
|
||||
return ((1 << (i + 1)) - 1);
|
||||
}
|
||||
|
||||
// Number of iterations to use for a given tree depth
|
||||
static int NumIters(int i) {
|
||||
return 2 * TreeSize(kStretchTreeDepth) / TreeSize(i);
|
||||
}
|
||||
|
||||
// Build tree top down, assigning to older objects.
|
||||
static void Populate(int iDepth, Node thisNode) {
|
||||
if (iDepth<=0) {
|
||||
return;
|
||||
} else {
|
||||
iDepth--;
|
||||
thisNode.left = new Node();
|
||||
thisNode.right = new Node();
|
||||
Populate (iDepth, thisNode.left);
|
||||
Populate (iDepth, thisNode.right);
|
||||
}
|
||||
}
|
||||
|
||||
// Build tree bottom-up
|
||||
static Node MakeTree(int iDepth) {
|
||||
if (iDepth<=0) {
|
||||
return new Node();
|
||||
} else {
|
||||
return new Node(MakeTree(iDepth-1),
|
||||
MakeTree(iDepth-1));
|
||||
}
|
||||
}
|
||||
|
||||
static void PrintDiagnostics() {
|
||||
long lFreeMemory = Runtime.getRuntime().freeMemory();
|
||||
long lTotalMemory = Runtime.getRuntime().totalMemory();
|
||||
|
||||
System.out.print(" Total memory available="
|
||||
+ lTotalMemory + " bytes");
|
||||
System.out.println(" Free memory=" + lFreeMemory + " bytes");
|
||||
}
|
||||
|
||||
static void TimeConstruction(int depth) {
|
||||
Node root;
|
||||
long tStart, tFinish;
|
||||
int iNumIters = NumIters(depth);
|
||||
Node tempTree;
|
||||
|
||||
System.out.println("Creating " + iNumIters +
|
||||
" trees of depth " + depth);
|
||||
tStart = System.currentTimeMillis();
|
||||
for (int i = 0; i < iNumIters; ++i) {
|
||||
tempTree = new Node();
|
||||
Populate(depth, tempTree);
|
||||
tempTree = null;
|
||||
}
|
||||
tFinish = System.currentTimeMillis();
|
||||
System.out.println("\tTop down construction took "
|
||||
+ (tFinish - tStart) + "msecs");
|
||||
tStart = System.currentTimeMillis();
|
||||
for (int i = 0; i < iNumIters; ++i) {
|
||||
tempTree = MakeTree(depth);
|
||||
tempTree = null;
|
||||
}
|
||||
tFinish = System.currentTimeMillis();
|
||||
System.out.println("\tBottom up construction took "
|
||||
+ (tFinish - tStart) + "msecs");
|
||||
|
||||
}
|
||||
|
||||
public static void main(String args[]) {
|
||||
Node root;
|
||||
Node longLivedTree;
|
||||
Node tempTree;
|
||||
long tStart, tFinish;
|
||||
long tElapsed;
|
||||
|
||||
|
||||
System.out.println("Garbage Collector Test");
|
||||
System.out.println(
|
||||
" Stretching memory with a binary tree of depth "
|
||||
+ kStretchTreeDepth);
|
||||
PrintDiagnostics();
|
||||
tStart = System.currentTimeMillis();
|
||||
|
||||
// Stretch the memory space quickly
|
||||
tempTree = MakeTree(kStretchTreeDepth);
|
||||
tempTree = null;
|
||||
|
||||
// Create a long lived object
|
||||
System.out.println(
|
||||
" Creating a long-lived binary tree of depth " +
|
||||
kLongLivedTreeDepth);
|
||||
longLivedTree = new Node();
|
||||
Populate(kLongLivedTreeDepth, longLivedTree);
|
||||
|
||||
// Create long-lived array, filling half of it
|
||||
System.out.println(
|
||||
" Creating a long-lived array of "
|
||||
+ kArraySize + " doubles");
|
||||
double array[] = new double[kArraySize];
|
||||
for (int i = 0; i < kArraySize/2; ++i) {
|
||||
array[i] = 1.0/i;
|
||||
}
|
||||
PrintDiagnostics();
|
||||
|
||||
for (int d = kMinTreeDepth; d <= kMaxTreeDepth; d += 2) {
|
||||
TimeConstruction(d);
|
||||
}
|
||||
|
||||
if (longLivedTree == null || array[1000] != 1.0/1000)
|
||||
System.out.println("Failed");
|
||||
// fake reference to LongLivedTree
|
||||
// and array
|
||||
// to keep them from being optimized away
|
||||
|
||||
tFinish = System.currentTimeMillis();
|
||||
tElapsed = tFinish-tStart;
|
||||
PrintDiagnostics();
|
||||
System.out.println("Completed in " + tElapsed + "ms.");
|
||||
}
|
||||
} // class JavaGC
|
||||
|
|
@ -1,301 +0,0 @@
|
|||
// This is adapted from a benchmark written by John Ellis and Pete Kovac
|
||||
// of Post Communications.
|
||||
// It was modified by Hans Boehm of Silicon Graphics.
|
||||
// Translated to C++ 30 May 1997 by William D Clinger of Northeastern Univ.
|
||||
//
|
||||
// This is no substitute for real applications. No actual application
|
||||
// is likely to behave in exactly this way. However, this benchmark was
|
||||
// designed to be more representative of real applications than other
|
||||
// Java GC benchmarks of which we are aware.
|
||||
// It attempts to model those properties of allocation requests that
|
||||
// are important to current GC techniques.
|
||||
// It is designed to be used either to obtain a single overall performance
|
||||
// number, or to give a more detailed estimate of how collector
|
||||
// performance varies with object lifetimes. It prints the time
|
||||
// required to allocate and collect balanced binary trees of various
|
||||
// sizes. Smaller trees result in shorter object lifetimes. Each cycle
|
||||
// allocates roughly the same amount of memory.
|
||||
// Two data structures are kept around during the entire process, so
|
||||
// that the measured performance is representative of applications
|
||||
// that maintain some live in-memory data. One of these is a tree
|
||||
// containing many pointers. The other is a large array containing
|
||||
// double precision floating point numbers. Both should be of comparable
|
||||
// size.
|
||||
//
|
||||
// The results are only really meaningful together with a specification
|
||||
// of how much memory was used. It is possible to trade memory for
|
||||
// better time performance. This benchmark should be run in a 32 MB
|
||||
// heap, though we don't currently know how to enforce that uniformly.
|
||||
//
|
||||
// Unlike the original Ellis and Kovac benchmark, we do not attempt
|
||||
// measure pause times. This facility should eventually be added back
|
||||
// in. There are several reasons for omitting it for now. The original
|
||||
// implementation depended on assumptions about the thread scheduler
|
||||
// that don't hold uniformly. The results really measure both the
|
||||
// scheduler and GC. Pause time measurements tend to not fit well with
|
||||
// current benchmark suites. As far as we know, none of the current
|
||||
// commercial Java implementations seriously attempt to minimize GC pause
|
||||
// times.
|
||||
|
||||
#include <new.h>
|
||||
#include <iostream.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
#ifdef GC
|
||||
# include "gc.h"
|
||||
#endif
|
||||
#ifdef OGC
|
||||
# include "ogc.h"
|
||||
#endif
|
||||
|
||||
// These macros were a quick hack for the Macintosh.
|
||||
//
|
||||
// #define currentTime() clock()
|
||||
// #define elapsedTime(x) ((1000*(x))/CLOCKS_PER_SEC)
|
||||
|
||||
#define currentTime() stats_rtclock()
|
||||
#define elapsedTime(x) (x)
|
||||
|
||||
/* Get the current time in milliseconds */
|
||||
|
||||
unsigned
|
||||
stats_rtclock( void )
|
||||
{
|
||||
struct timeval t;
|
||||
struct timezone tz;
|
||||
|
||||
if (gettimeofday( &t, &tz ) == -1)
|
||||
return 0;
|
||||
return (t.tv_sec * 1000 + t.tv_usec / 1000);
|
||||
}
|
||||
|
||||
static const int kStretchTreeDepth = 18; // about 16Mb
|
||||
static const int kLongLivedTreeDepth = 16; // about 4Mb
|
||||
static const int kArraySize = 500000; // about 4Mb
|
||||
static const int kMinTreeDepth = 4;
|
||||
static const int kMaxTreeDepth = 16;
|
||||
|
||||
struct Node0 {
|
||||
# ifdef OGC
|
||||
gc_ptr<Node0> left;
|
||||
gc_ptr<Node0> right;
|
||||
Node0(gc_ptr<Node0> l, gc_ptr<Node0> r) { left = l; right = r; }
|
||||
# else
|
||||
Node0 * left;
|
||||
Node0 * right;
|
||||
Node0(Node0 *l, Node0 *r) { left = l; right = r; }
|
||||
# endif
|
||||
int i, j;
|
||||
Node0() { left = 0; right = 0; }
|
||||
# if !defined(GC) && !defined(OGC)
|
||||
~Node0() { if (left) delete left; if (right) delete right; }
|
||||
# endif
|
||||
};
|
||||
|
||||
#ifdef OGC
|
||||
typedef gc_ptr<Node0> Node;
|
||||
#else
|
||||
typedef struct Node0 *Node;
|
||||
#endif
|
||||
|
||||
struct GCBench {
|
||||
|
||||
// Nodes used by a tree of a given size
|
||||
static int TreeSize(int i) {
|
||||
return ((1 << (i + 1)) - 1);
|
||||
}
|
||||
|
||||
// Number of iterations to use for a given tree depth
|
||||
static int NumIters(int i) {
|
||||
return 2 * TreeSize(kStretchTreeDepth) / TreeSize(i);
|
||||
}
|
||||
|
||||
// Build tree top down, assigning to older objects.
|
||||
static void Populate(int iDepth, Node thisNode) {
|
||||
if (iDepth<=0) {
|
||||
return;
|
||||
} else {
|
||||
iDepth--;
|
||||
# if defined(GC)
|
||||
thisNode->left = new (GC_NEW(Node0)) Node0();
|
||||
thisNode->right = new (GC_NEW(Node0)) Node0();
|
||||
# elif defined(OGC)
|
||||
thisNode->left = gc_new Node0();
|
||||
thisNode->right = gc_new Node0();
|
||||
# else
|
||||
thisNode->left = new Node0();
|
||||
thisNode->right = new Node0();
|
||||
# endif
|
||||
Populate (iDepth, thisNode->left);
|
||||
Populate (iDepth, thisNode->right);
|
||||
}
|
||||
}
|
||||
|
||||
// Build tree bottom-up
|
||||
static Node MakeTree(int iDepth) {
|
||||
if (iDepth<=0) {
|
||||
# if defined(GC)
|
||||
return new (GC_NEW(Node0)) Node0();
|
||||
# elif defined(OGC)
|
||||
return gc_new Node0();
|
||||
# else
|
||||
return new Node0();
|
||||
# endif
|
||||
} else {
|
||||
# if defined(GC)
|
||||
return new (GC_NEW(Node0)) Node0(MakeTree(iDepth-1),
|
||||
MakeTree(iDepth-1));
|
||||
# elif defined(OGC)
|
||||
# ifdef BROKEN_SMART_PTRS
|
||||
Node left = MakeTree(iDepth-1);
|
||||
Node right = MakeTree(iDepth-1);
|
||||
return gc_new Node0(left, right);
|
||||
# else
|
||||
return gc_new Node0(MakeTree(iDepth-1),
|
||||
MakeTree(iDepth-1));
|
||||
# endif
|
||||
# else
|
||||
return new Node0(MakeTree(iDepth-1),
|
||||
MakeTree(iDepth-1));
|
||||
# endif
|
||||
}
|
||||
}
|
||||
|
||||
static void PrintDiagnostics() {
|
||||
#if 0
|
||||
long lFreeMemory = Runtime.getRuntime().freeMemory();
|
||||
long lTotalMemory = Runtime.getRuntime().totalMemory();
|
||||
|
||||
System.out.print(" Total memory available="
|
||||
+ lTotalMemory + " bytes");
|
||||
System.out.println(" Free memory=" + lFreeMemory + " bytes");
|
||||
#endif
|
||||
}
|
||||
|
||||
static void TimeConstruction(int depth) {
|
||||
long tStart, tFinish;
|
||||
int iNumIters = NumIters(depth);
|
||||
Node tempTree;
|
||||
|
||||
cout << "Creating " << iNumIters
|
||||
<< " trees of depth " << depth << endl;
|
||||
|
||||
tStart = currentTime();
|
||||
for (int i = 0; i < iNumIters; ++i) {
|
||||
# if defined(GC)
|
||||
tempTree = new (GC_NEW(Node0)) Node0();
|
||||
# elif defined(OGC)
|
||||
tempTree = gc_new Node0();
|
||||
# else
|
||||
tempTree = new Node0();
|
||||
# endif
|
||||
Populate(depth, tempTree);
|
||||
# if !defined(GC) && !defined(OGC)
|
||||
delete tempTree;
|
||||
# endif
|
||||
tempTree = 0;
|
||||
}
|
||||
tFinish = currentTime();
|
||||
cout << "\tTop down construction took "
|
||||
<< elapsedTime(tFinish - tStart) << " msec" << endl;
|
||||
|
||||
tStart = currentTime();
|
||||
for (int i = 0; i < iNumIters; ++i) {
|
||||
tempTree = MakeTree(depth);
|
||||
# if !defined(GC) && !defined(OGC)
|
||||
delete tempTree;
|
||||
# endif
|
||||
tempTree = 0;
|
||||
}
|
||||
tFinish = currentTime();
|
||||
cout << "\tBottom up construction took "
|
||||
<< elapsedTime(tFinish - tStart) << " msec" << endl;
|
||||
|
||||
}
|
||||
|
||||
void main() {
|
||||
Node root;
|
||||
Node longLivedTree;
|
||||
Node tempTree;
|
||||
long tStart, tFinish;
|
||||
long tElapsed;
|
||||
|
||||
#ifdef GC
|
||||
// GC_full_freq = 30;
|
||||
GC_enable_incremental();
|
||||
#endif
|
||||
|
||||
# ifdef OGC
|
||||
GC::SetPolicy(100);
|
||||
# endif
|
||||
cout << "Garbage Collector Test" << endl;
|
||||
cout << " Live storage will peak at "
|
||||
<< 2 * sizeof(Node0) * TreeSize(kLongLivedTreeDepth) +
|
||||
sizeof(double) * kArraySize
|
||||
<< " bytes." << endl << endl;
|
||||
cout << " Stretching memory with a binary tree of depth "
|
||||
<< kStretchTreeDepth << endl;
|
||||
PrintDiagnostics();
|
||||
|
||||
tStart = currentTime();
|
||||
|
||||
// Stretch the memory space quickly
|
||||
tempTree = MakeTree(kStretchTreeDepth);
|
||||
# if !defined(GC) && !defined(OGC)
|
||||
delete tempTree;
|
||||
# endif
|
||||
tempTree = 0;
|
||||
|
||||
// Create a long lived object
|
||||
cout << " Creating a long-lived binary tree of depth "
|
||||
<< kLongLivedTreeDepth << endl;
|
||||
# if defined(GC)
|
||||
longLivedTree = new (GC_NEW(Node0)) Node0();
|
||||
# elif defined(OGC)
|
||||
longLivedTree = gc_new Node0();
|
||||
# else
|
||||
longLivedTree = new Node0();
|
||||
# endif
|
||||
Populate(kLongLivedTreeDepth, longLivedTree);
|
||||
|
||||
// Create long-lived array, filling half of it
|
||||
cout << " Creating a long-lived array of "
|
||||
<< kArraySize << " doubles" << endl;
|
||||
# if defined(GC)
|
||||
double *array = (double *)
|
||||
GC_MALLOC(sizeof(double) * kArraySize);
|
||||
# else
|
||||
double *array = new double[kArraySize];
|
||||
# endif
|
||||
for (int i = 0; i < kArraySize/2; ++i) {
|
||||
array[i] = 1.0/i;
|
||||
}
|
||||
PrintDiagnostics();
|
||||
|
||||
for (int d = kMinTreeDepth; d <= kMaxTreeDepth; d += 2)
|
||||
{
|
||||
TimeConstruction(d);
|
||||
}
|
||||
|
||||
if (longLivedTree == 0 || array[1000] != 1.0/1000)
|
||||
cout << "Failed" << endl;
|
||||
// fake reference to LongLivedTree
|
||||
// and array
|
||||
// to keep them from being optimized away
|
||||
|
||||
tFinish = currentTime();
|
||||
tElapsed = elapsedTime(tFinish-tStart);
|
||||
PrintDiagnostics();
|
||||
cout << "Completed in " << tElapsed << " msec" << endl;
|
||||
# ifdef GC
|
||||
cout << "Completed " << GC_gc_no << " collections" <<endl;
|
||||
cout << "Heap size is " << GC_get_heap_size() << endl;
|
||||
# endif
|
||||
}
|
||||
};
|
||||
|
||||
main () {
|
||||
GCBench x;
|
||||
x.main();
|
||||
}
|
||||
|
||||
|
|
@ -1,172 +0,0 @@
|
|||
# This is adapted from a benchmark written by John Ellis and Pete Kovac
|
||||
# of Post Communications.
|
||||
# It was modified by Hans Boehm of Silicon Graphics.
|
||||
#
|
||||
# This is no substitute for real applications. No actual application
|
||||
# is likely to behave in exactly this way. However, this benchmark was
|
||||
# designed to be more representative of real applications than other
|
||||
# Java GC benchmarks of which we are aware.
|
||||
# It attempts to model those properties of allocation requests that
|
||||
# are important to current GC techniques.
|
||||
# It is designed to be used either to obtain a single overall performance
|
||||
# number, or to give a more detailed estimate of how collector
|
||||
# performance varies with object lifetimes. It prints the time
|
||||
# required to allocate and collect balanced binary trees of various
|
||||
# sizes. Smaller trees result in shorter object lifetimes. Each cycle
|
||||
# allocates roughly the same amount of memory.
|
||||
# Two data structures are kept around during the entire process, so
|
||||
# that the measured performance is representative of applications
|
||||
# that maintain some live in-memory data. One of these is a tree
|
||||
# containing many pointers. The other is a large array containing
|
||||
# double precision floating point numbers. Both should be of comparable
|
||||
# size.
|
||||
#
|
||||
# The results are only really meaningful together with a specification
|
||||
# of how much memory was used. It is possible to trade memory for
|
||||
# better time performance. This benchmark should be run in a 32 MB
|
||||
# heap, though we don't currently know how to enforce that uniformly.
|
||||
#
|
||||
# Unlike the original Ellis and Kovac benchmark, we do not attempt
|
||||
# measure pause times. This facility should eventually be added back
|
||||
# in. There are several reasons for omitting it for now. The original
|
||||
# implementation depended on assumptions about the thread scheduler
|
||||
# that don't hold uniformly. The results really measure both the
|
||||
# scheduler and GC. Pause time measurements tend to not fit well with
|
||||
# current benchmark suites. As far as we know, none of the current
|
||||
# commercial Java implementations seriously attempt to minimize GC pause
|
||||
# times.
|
||||
#
|
||||
# Known deficiencies:
|
||||
# - No way to check on memory use
|
||||
# - No cyclic data structures
|
||||
# - No attempt to measure variation with object size
|
||||
# - Results are sensitive to locking cost, but we dont
|
||||
# check for proper locking
|
||||
#
|
||||
|
||||
import
|
||||
io, strutils, times
|
||||
|
||||
type
|
||||
PNode = ref TNode
|
||||
TNode = record
|
||||
left, right: PNode
|
||||
i, j: int
|
||||
|
||||
proc newNode(l, r: PNode): PNode =
|
||||
new(result)
|
||||
result.left = l
|
||||
result.right = r
|
||||
|
||||
const
|
||||
kStretchTreeDepth = 18 # about 16Mb
|
||||
kLongLivedTreeDepth = 16 # about 4Mb
|
||||
kArraySize = 500000 # about 4Mb
|
||||
kMinTreeDepth = 4
|
||||
kMaxTreeDepth = 16
|
||||
|
||||
# Nodes used by a tree of a given size
|
||||
proc TreeSize(i: int): int = return ((1 shl (i + 1)) - 1)
|
||||
|
||||
# Number of iterations to use for a given tree depth
|
||||
proc NumIters(i: int): int =
|
||||
return 2 * TreeSize(kStretchTreeDepth) div TreeSize(i)
|
||||
|
||||
# Build tree top down, assigning to older objects.
|
||||
proc Populate(iDepth: int, thisNode: PNode) =
|
||||
if iDepth <= 0:
|
||||
return
|
||||
else:
|
||||
new(thisNode.left)
|
||||
new(thisNode.right)
|
||||
Populate(iDepth-1, thisNode.left)
|
||||
Populate(iDepth-1, thisNode.right)
|
||||
|
||||
# Build tree bottom-up
|
||||
proc MakeTree(iDepth: int): PNode =
|
||||
if iDepth <= 0:
|
||||
new(result)
|
||||
else:
|
||||
return newNode(MakeTree(iDepth-1),
|
||||
MakeTree(iDepth-1))
|
||||
|
||||
proc PrintDiagnostics() =
|
||||
var
|
||||
FreeMemory = getFreeMem()
|
||||
TotalMemory = getTotalMem()
|
||||
|
||||
echo("Total memory available: " & $TotalMemory & " bytes")
|
||||
echo("Free memory: " & $FreeMemory & " bytes")
|
||||
|
||||
proc TimeConstruction(depth: int) =
|
||||
var
|
||||
root, tempTree: PNode
|
||||
t: int
|
||||
iNumIters: int
|
||||
|
||||
iNumIters = NumIters(depth)
|
||||
|
||||
echo("Creating " & $iNumIters & " trees of depth " & $depth)
|
||||
t = getStartMilsecs()
|
||||
for i in 0..iNumIters-1:
|
||||
new(tempTree)
|
||||
Populate(depth, tempTree)
|
||||
tempTree = nil
|
||||
echo("\tTop down construction took " &
|
||||
$(getStartMilsecs() - t) & "msecs")
|
||||
t = getStartMilsecs()
|
||||
for i in 0..iNumIters-1:
|
||||
tempTree = MakeTree(depth)
|
||||
tempTree = nil
|
||||
echo("\tBottom up construction took " &
|
||||
$(getStartMilsecs() - t) & "msecs")
|
||||
|
||||
type
|
||||
tMyArray = seq[float]
|
||||
|
||||
proc main() =
|
||||
var
|
||||
root, longLivedTree, tempTree: PNode
|
||||
t: int
|
||||
myarray: tMyArray
|
||||
|
||||
echo("Garbage Collector Test")
|
||||
echo(" Stretching memory with a binary tree of depth " &
|
||||
$kStretchTreeDepth)
|
||||
PrintDiagnostics()
|
||||
t = getStartMilsecs()
|
||||
|
||||
# Stretch the memory space quickly
|
||||
tempTree = MakeTree(kStretchTreeDepth)
|
||||
tempTree = nil
|
||||
|
||||
# Create a long lived object
|
||||
echo(" Creating a long-lived binary tree of depth " &
|
||||
$kLongLivedTreeDepth)
|
||||
new(longLivedTree)
|
||||
Populate(kLongLivedTreeDepth, longLivedTree)
|
||||
|
||||
# Create long-lived array, filling half of it
|
||||
echo(" Creating a long-lived array of " & $kArraySize & " doubles")
|
||||
myarray = []
|
||||
setlength(myarray, kArraySize)
|
||||
for i in 0..kArraySize div 2 -1:
|
||||
myarray[i] = 1.0 / toFloat(i)
|
||||
|
||||
PrintDiagnostics()
|
||||
|
||||
var d = kMinTreeDepth
|
||||
while d <= kMaxTreeDepth:
|
||||
TimeConstruction(d)
|
||||
inc(d, 2)
|
||||
|
||||
if longLivedTree == nil or myarray[1000] != 1.0/1000.0:
|
||||
echo("Failed")
|
||||
# fake reference to LongLivedTree
|
||||
# and array to keep them from being optimized away
|
||||
|
||||
var elapsed = getStartMilsecs() - t
|
||||
PrintDiagnostics()
|
||||
echo("Completed in " & $elapsed & "ms.")
|
||||
|
||||
main()
|
||||
|
|
@ -1,63 +0,0 @@
|
|||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
/* A very simple profiler. Note that it should be possible to */
|
||||
/* get function level information by concatenating this with nm */
|
||||
/* output and running the result through the sort utility. */
|
||||
/* This assumes that all interesting parts of the executable */
|
||||
/* are statically linked. */
|
||||
|
||||
static size_t buf_size;
|
||||
static u_short *profil_buf;
|
||||
|
||||
# ifdef __i386__
|
||||
# ifndef COMPRESSION
|
||||
# define COMPRESSION 1
|
||||
# endif
|
||||
# define TEXT_START 0x08000000
|
||||
# define PTR_DIGS 8
|
||||
# endif
|
||||
# ifdef __ia64__
|
||||
# ifndef COMPRESSION
|
||||
# define COMPRESSION 8
|
||||
# endif
|
||||
# define TEXT_START 0x4000000000000000
|
||||
# define PTR_DIGS 16
|
||||
# endif
|
||||
|
||||
extern int etext;
|
||||
|
||||
/*
|
||||
* Note that the ith entry in the profile buffer corresponds to
|
||||
* a PC value of TEXT_START + i * COMPRESSION * 2.
|
||||
* The extra factor of 2 is not apparent from the documentation,
|
||||
* but it is explicit in the glibc source.
|
||||
*/
|
||||
|
||||
void init_profiling()
|
||||
{
|
||||
buf_size = ((size_t)(&etext) - TEXT_START + 0x10)/COMPRESSION/2;
|
||||
profil_buf = calloc(buf_size, sizeof(u_short));
|
||||
if (profil_buf == 0) {
|
||||
fprintf(stderr, "Could not allocate profile buffer\n");
|
||||
}
|
||||
profil(profil_buf, buf_size * sizeof(u_short),
|
||||
TEXT_START, 65536/COMPRESSION);
|
||||
}
|
||||
|
||||
void dump_profile()
|
||||
{
|
||||
size_t i;
|
||||
size_t sum = 0;
|
||||
for (i = 0; i < buf_size; ++i) {
|
||||
if (profil_buf[i] != 0) {
|
||||
fprintf(stderr, "%0*lx\t%d !PROF!\n",
|
||||
PTR_DIGS,
|
||||
TEXT_START + i * COMPRESSION * 2,
|
||||
profil_buf[i]);
|
||||
sum += profil_buf[i];
|
||||
}
|
||||
}
|
||||
fprintf(stderr, "Total number of samples was %ld !PROF!\n", sum);
|
||||
}
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
USEUNIT("morc_gen\gctest.c");
|
||||
USEUNIT("..\lib\dlmalloc.c");
|
||||
USEUNIT("..\lib\morc_gen\io.c");
|
||||
USEUNIT("..\lib\morc_gen\strutils.c");
|
||||
USEUNIT("..\lib\morc_gen\system.c");
|
||||
//---------------------------------------------------------------------------
|
||||
This file is used by the project manager only and should be treated like the project file
|
||||
|
||||
main
|
||||
85
tests/gc.bpr
85
tests/gc.bpr
|
|
@ -1,85 +0,0 @@
|
|||
<?xml version='1.0' encoding='utf-8' ?>
|
||||
<!-- C++Builder XML Project -->
|
||||
<PROJECT>
|
||||
<MACROS>
|
||||
<VERSION value="BCB.05.03"/>
|
||||
<PROJECT value="gc.exe"/>
|
||||
<OBJFILES value="morc_gen\gctest.obj ..\lib\dlmalloc.obj ..\lib\morc_gen\io.obj
|
||||
..\lib\morc_gen\strutils.obj ..\lib\morc_gen\system.obj"/>
|
||||
<RESFILES value=""/>
|
||||
<DEFFILE value=""/>
|
||||
<RESDEPEN value="$(RESFILES)"/>
|
||||
<LIBFILES value=""/>
|
||||
<LIBRARIES value=""/>
|
||||
<SPARELIBS value=""/>
|
||||
<PACKAGES value="Vcl50.bpi Vclx50.bpi bcbsmp50.bpi dclocx50.bpi bcb2kaxserver50.bpi"/>
|
||||
<PATHCPP value=".;morc_gen;..\lib;..\lib\morc_gen"/>
|
||||
<PATHPAS value=".;"/>
|
||||
<PATHRC value=".;"/>
|
||||
<PATHASM value=".;"/>
|
||||
<DEBUGLIBPATH value="$(BCB)\lib\debug"/>
|
||||
<RELEASELIBPATH value="$(BCB)\lib\release"/>
|
||||
<LINKER value="tlink32"/>
|
||||
<USERDEFINES value="_DEBUG"/>
|
||||
<SYSDEFINES value="NO_STRICT;_NO_VCL;_RTLDLL;USEPACKAGES"/>
|
||||
<MAINSOURCE value="gc.bpf"/>
|
||||
<INCLUDEPATH value="..\lib\morc_gen;..\lib;morc_gen;$(BCB)\include;$(BCB)\include\vcl"/>
|
||||
<LIBPATH value="..\lib\morc_gen;..\lib;morc_gen;$(BCB)\lib\obj;$(BCB)\lib"/>
|
||||
<WARNINGS value="-w-par"/>
|
||||
</MACROS>
|
||||
<OPTIONS>
|
||||
<CFLAG1 value="-tWC -tWM- -Od -H=$(BCB)\lib\vcl50.csm -Hc -Vx -Ve -X- -r- -a8 -b- -k -y
|
||||
-v -vi- -c"/>
|
||||
<PFLAGS value="-$YD -$W -$O- -v -JPHNE -M"/>
|
||||
<RFLAGS value=""/>
|
||||
<AFLAGS value="/mx /w2 /zd"/>
|
||||
<LFLAGS value="-Tpe -ap -D"" -x -Gn -v"/>
|
||||
</OPTIONS>
|
||||
<LINKER>
|
||||
<ALLOBJ value="c0x32.obj $(PACKAGES) $(OBJFILES)"/>
|
||||
<ALLRES value="$(RESFILES)"/>
|
||||
<ALLLIB value="$(LIBFILES) $(LIBRARIES) import32.lib cw32i.lib"/>
|
||||
</LINKER>
|
||||
<IDEOPTIONS>
|
||||
[Version Info]
|
||||
IncludeVerInfo=0
|
||||
AutoIncBuild=0
|
||||
MajorVer=1
|
||||
MinorVer=0
|
||||
Release=0
|
||||
Build=0
|
||||
Debug=0
|
||||
PreRelease=0
|
||||
Special=0
|
||||
Private=0
|
||||
DLL=0
|
||||
Locale=1031
|
||||
CodePage=1252
|
||||
|
||||
[Version Info Keys]
|
||||
CompanyName=
|
||||
FileDescription=
|
||||
FileVersion=1.0.0.0
|
||||
InternalName=
|
||||
LegalCopyright=
|
||||
LegalTrademarks=
|
||||
OriginalFilename=
|
||||
ProductName=
|
||||
ProductVersion=1.0.0.0
|
||||
Comments=
|
||||
|
||||
[Debugging]
|
||||
DebugSourceDirs=$(BCB)\source\vcl
|
||||
|
||||
[Parameters]
|
||||
RunParams=
|
||||
HostApplication=
|
||||
RemoteHost=
|
||||
RemotePath=
|
||||
RemoteDebug=0
|
||||
|
||||
[Compiler]
|
||||
ShowInfoMsgs=0
|
||||
LinkDebugVcl=0
|
||||
</IDEOPTIONS>
|
||||
</PROJECT>
|
||||
|
|
@ -6,31 +6,40 @@ import
|
|||
|
||||
type
|
||||
PNode = ref TNode
|
||||
TNode = record
|
||||
TNode {.final.} = object
|
||||
le, ri: PNode
|
||||
data: string
|
||||
|
||||
TTable = record
|
||||
TTable {.final.} = object
|
||||
counter, max: int
|
||||
data: seq[string]
|
||||
|
||||
TBNode = record
|
||||
TBNode {.final.} = object
|
||||
other: PNode # a completely different tree
|
||||
data: string
|
||||
sons: seq[TBNode] # directly embedded!
|
||||
t: TTable
|
||||
|
||||
TCaseKind = enum nkStr, nkList
|
||||
TCaseKind = enum nkStr, nkWhole, nkList
|
||||
PCaseNode = ref TCaseNode
|
||||
TCaseNode = record
|
||||
TCaseNode {.final.} = object
|
||||
case kind: TCaseKind
|
||||
of nkStr: data: string
|
||||
of nkList: sons: seq[PCaseNode]
|
||||
else: unused: seq[string]
|
||||
|
||||
var
|
||||
flip: int
|
||||
|
||||
proc newCaseNode(data: string): PCaseNode =
|
||||
new(result)
|
||||
result.kind = nkStr
|
||||
result.data = data
|
||||
if flip == 0:
|
||||
result.kind = nkStr
|
||||
result.data = data
|
||||
else:
|
||||
result.kind = nkWhole
|
||||
result.unused = ["", "abc", "abdc"]
|
||||
flip = 1 - flip
|
||||
|
||||
proc newCaseNode(a, b: PCaseNode): PCaseNode =
|
||||
new(result)
|
||||
|
|
@ -44,7 +53,8 @@ proc caseTree(lvl: int = 0): PCaseNode =
|
|||
proc finalizeBNode(n: TBNode) = writeln(stdout, n.data)
|
||||
proc finalizeNode(n: PNode) =
|
||||
assert(n != nil)
|
||||
writeln(stdout, n.data)
|
||||
if isNil(n.data): writeln(stdout, "nil!")
|
||||
else: writeln(stdout, n.data)
|
||||
|
||||
var
|
||||
id: int = 1
|
||||
|
|
|
|||
|
|
@ -1,10 +0,0 @@
|
|||
USEUNIT("rod_gen\thallo.c");
|
||||
USEUNIT("..\lib\rod_gen\os.c");
|
||||
USEUNIT("..\lib\rod_gen\strutils.c");
|
||||
USEUNIT("..\lib\rod_gen\system.c");
|
||||
USEUNIT("..\lib\rod_gen\times.c");
|
||||
USEUNIT("..\lib\dlmalloc.c");
|
||||
//---------------------------------------------------------------------------
|
||||
This file is used by the project manager only and should be treated like the project file
|
||||
|
||||
main
|
||||
102
tests/hallo.bpr
102
tests/hallo.bpr
|
|
@ -1,102 +0,0 @@
|
|||
<?xml version='1.0' encoding='utf-8' ?>
|
||||
<!-- C++Builder XML Project -->
|
||||
<PROJECT>
|
||||
<MACROS>
|
||||
<VERSION value="BCB.05.03"/>
|
||||
<PROJECT value="hallo.exe"/>
|
||||
<OBJFILES value="rod_gen\thallo.obj ..\lib\rod_gen\os.obj ..\lib\rod_gen\strutils.obj
|
||||
..\lib\rod_gen\system.obj ..\lib\rod_gen\times.obj ..\lib\dlmalloc.obj"/>
|
||||
<RESFILES value=""/>
|
||||
<DEFFILE value=""/>
|
||||
<RESDEPEN value="$(RESFILES)"/>
|
||||
<LIBFILES value=""/>
|
||||
<LIBRARIES value=""/>
|
||||
<SPARELIBS value=""/>
|
||||
<PACKAGES value="Vcl50.bpi Vclx50.bpi bcbsmp50.bpi dclocx50.bpi bcb2kaxserver50.bpi"/>
|
||||
<PATHCPP value=".;rod_gen;..\lib\rod_gen;..\lib"/>
|
||||
<PATHPAS value=".;"/>
|
||||
<PATHRC value=".;"/>
|
||||
<PATHASM value=".;"/>
|
||||
<DEBUGLIBPATH value="$(BCB)\lib\debug"/>
|
||||
<RELEASELIBPATH value="$(BCB)\lib\release"/>
|
||||
<LINKER value="tlink32"/>
|
||||
<USERDEFINES value="_DEBUG"/>
|
||||
<SYSDEFINES value="NO_STRICT;_NO_VCL;_RTLDLL;USEPACKAGES"/>
|
||||
<MAINSOURCE value="hallo.bpf"/>
|
||||
<INCLUDEPATH value="..\lib\rod_gen;rod_gen;$(BCB)\include;$(BCB)\include\vcl;..\lib"/>
|
||||
<LIBPATH value="..\lib;..\lib\rod_gen;rod_gen;$(BCB)\lib\obj;$(BCB)\lib"/>
|
||||
<WARNINGS value="-w-par"/>
|
||||
</MACROS>
|
||||
<OPTIONS>
|
||||
<CFLAG1 value="-Od -H=$(BCB)\lib\vcl50.csm -Hc -Vx -Ve -X- -r- -a8 -b- -k -y -v -vi- -tWC
|
||||
-tWM- -c"/>
|
||||
<PFLAGS value="-$YD -$W -$O- -v -JPHNE -M"/>
|
||||
<RFLAGS value=""/>
|
||||
<AFLAGS value="/mx /w2 /zd"/>
|
||||
<LFLAGS value="-D"" -ap -Tpe -x -Gn -v"/>
|
||||
</OPTIONS>
|
||||
<LINKER>
|
||||
<ALLOBJ value="c0x32.obj $(PACKAGES) $(OBJFILES)"/>
|
||||
<ALLRES value="$(RESFILES)"/>
|
||||
<ALLLIB value="$(LIBFILES) $(LIBRARIES) import32.lib cw32i.lib"/>
|
||||
</LINKER>
|
||||
<IDEOPTIONS>
|
||||
[Version Info]
|
||||
IncludeVerInfo=0
|
||||
AutoIncBuild=0
|
||||
MajorVer=1
|
||||
MinorVer=0
|
||||
Release=0
|
||||
Build=0
|
||||
Debug=0
|
||||
PreRelease=0
|
||||
Special=0
|
||||
Private=0
|
||||
DLL=0
|
||||
Locale=1031
|
||||
CodePage=1252
|
||||
|
||||
[Version Info Keys]
|
||||
CompanyName=
|
||||
FileDescription=
|
||||
FileVersion=1.0.0.0
|
||||
InternalName=
|
||||
LegalCopyright=
|
||||
LegalTrademarks=
|
||||
OriginalFilename=
|
||||
ProductName=
|
||||
ProductVersion=1.0.0.0
|
||||
Comments=
|
||||
|
||||
[HistoryLists\hlIncludePath]
|
||||
Count=2
|
||||
Item0=..\lib\rod_gen;rod_gen;$(BCB)\include;$(BCB)\include\vcl;E:\nimrod\lib
|
||||
Item1=..\lib\rod_gen;rod_gen;$(BCB)\include;$(BCB)\include\vcl
|
||||
|
||||
[HistoryLists\hlLibraryPath]
|
||||
Count=1
|
||||
Item0=..\lib\rod_gen;rod_gen;$(BCB)\lib\obj;$(BCB)\lib
|
||||
|
||||
[HistoryLists\hlDebugSourcePath]
|
||||
Count=1
|
||||
Item0=$(BCB)\source\vcl
|
||||
|
||||
[HistoryLists\hlConditionals]
|
||||
Count=1
|
||||
Item0=_DEBUG
|
||||
|
||||
[Debugging]
|
||||
DebugSourceDirs=$(BCB)\source\vcl
|
||||
|
||||
[Parameters]
|
||||
RunParams=
|
||||
HostApplication=
|
||||
RemoteHost=
|
||||
RemotePath=
|
||||
RemoteDebug=0
|
||||
|
||||
[Compiler]
|
||||
ShowInfoMsgs=0
|
||||
LinkDebugVcl=0
|
||||
</IDEOPTIONS>
|
||||
</PROJECT>
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
USEUNIT("tio.c");
|
||||
USEUNIT("..\lib\refcgc.c");
|
||||
USEUNIT("..\lib\io.c");
|
||||
USEUNIT("..\lib\morbase.c");
|
||||
USEUNIT("..\lib\morlib.c");
|
||||
//---------------------------------------------------------------------------
|
||||
This file is used by the project manager only and should be treated like the project file
|
||||
|
||||
|
||||
main
|
||||
|
|
@ -1,84 +0,0 @@
|
|||
<?xml version='1.0' encoding='utf-8' ?>
|
||||
<!-- C++Builder XML Project -->
|
||||
<PROJECT>
|
||||
<MACROS>
|
||||
<VERSION value="BCB.05.03"/>
|
||||
<PROJECT value="iotest.exe"/>
|
||||
<OBJFILES value="tio.obj ..\lib\refcgc.obj ..\lib\io.obj ..\lib\morbase.obj ..\lib\morlib.obj"/>
|
||||
<RESFILES value=""/>
|
||||
<DEFFILE value=""/>
|
||||
<RESDEPEN value="$(RESFILES)"/>
|
||||
<LIBFILES value=""/>
|
||||
<LIBRARIES value=""/>
|
||||
<SPARELIBS value=""/>
|
||||
<PACKAGES value="Vcl50.bpi Vclx50.bpi bcbsmp50.bpi dclocx50.bpi bcb2kaxserver50.bpi"/>
|
||||
<PATHCPP value=".;..\lib"/>
|
||||
<PATHPAS value=".;"/>
|
||||
<PATHRC value=".;"/>
|
||||
<PATHASM value=".;"/>
|
||||
<DEBUGLIBPATH value="$(BCB)\lib\debug"/>
|
||||
<RELEASELIBPATH value="$(BCB)\lib\release"/>
|
||||
<LINKER value="tlink32"/>
|
||||
<USERDEFINES value="_DEBUG"/>
|
||||
<SYSDEFINES value="NO_STRICT;_NO_VCL;_RTLDLL;USEPACKAGES"/>
|
||||
<MAINSOURCE value="iotest.bpf"/>
|
||||
<INCLUDEPATH value="..\lib;$(BCB)\include;$(BCB)\include\vcl"/>
|
||||
<LIBPATH value="..\lib;$(BCB)\lib\obj;$(BCB)\lib"/>
|
||||
<WARNINGS value="-w-par"/>
|
||||
</MACROS>
|
||||
<OPTIONS>
|
||||
<CFLAG1 value="-Od -H=$(BCB)\lib\vcl50.csm -Hc -w- -Vx -Ve -X- -r- -a8 -b- -k -y -v -vi-
|
||||
-tWC -tWM- -c"/>
|
||||
<PFLAGS value="-$YD -$W -$O- -v -JPHNE -M"/>
|
||||
<RFLAGS value=""/>
|
||||
<AFLAGS value="/mx /w2 /zd"/>
|
||||
<LFLAGS value="-D"" -ap -Tpe -x -Gn -v"/>
|
||||
</OPTIONS>
|
||||
<LINKER>
|
||||
<ALLOBJ value="c0x32.obj $(PACKAGES) $(OBJFILES)"/>
|
||||
<ALLRES value="$(RESFILES)"/>
|
||||
<ALLLIB value="$(LIBFILES) $(LIBRARIES) import32.lib cw32i.lib"/>
|
||||
</LINKER>
|
||||
<IDEOPTIONS>
|
||||
[Version Info]
|
||||
IncludeVerInfo=0
|
||||
AutoIncBuild=0
|
||||
MajorVer=1
|
||||
MinorVer=0
|
||||
Release=0
|
||||
Build=0
|
||||
Debug=0
|
||||
PreRelease=0
|
||||
Special=0
|
||||
Private=0
|
||||
DLL=0
|
||||
Locale=1031
|
||||
CodePage=1252
|
||||
|
||||
[Version Info Keys]
|
||||
CompanyName=
|
||||
FileDescription=
|
||||
FileVersion=1.0.0.0
|
||||
InternalName=
|
||||
LegalCopyright=
|
||||
LegalTrademarks=
|
||||
OriginalFilename=
|
||||
ProductName=
|
||||
ProductVersion=1.0.0.0
|
||||
Comments=
|
||||
|
||||
[Debugging]
|
||||
DebugSourceDirs=$(BCB)\source\vcl
|
||||
|
||||
[Parameters]
|
||||
RunParams=
|
||||
HostApplication=
|
||||
RemoteHost=
|
||||
RemotePath=
|
||||
RemoteDebug=0
|
||||
|
||||
[Compiler]
|
||||
ShowInfoMsgs=0
|
||||
LinkDebugVcl=0
|
||||
</IDEOPTIONS>
|
||||
</PROJECT>
|
||||
|
|
@ -1,6 +1,2 @@
|
|||
# Test the new initialization for modules
|
||||
|
||||
import
|
||||
io
|
||||
|
||||
write(stdout, "Hallo from module! ")
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
type
|
||||
TLexer* = record
|
||||
TLexer* {.final.} = object
|
||||
line*: int
|
||||
filename*: string
|
||||
buffer: cstring
|
||||
|
|
|
|||
|
|
@ -1,6 +0,0 @@
|
|||
# Test the error message
|
||||
|
||||
proc main() =
|
||||
main()
|
||||
|
||||
main()
|
||||
|
|
@ -12,7 +12,7 @@ import
|
|||
lexbase, os, strutils
|
||||
|
||||
type
|
||||
TMyRec = record # describes a record
|
||||
TMyRec {.final.} = object
|
||||
x, y: int # coordinates
|
||||
c: char # a character
|
||||
a: int32 # an integer
|
||||
|
|
|
|||
|
|
@ -1,8 +0,0 @@
|
|||
USEUNIT("tseqcon.c");
|
||||
USEUNIT("..\lib\io.c");
|
||||
USEUNIT("..\lib\morsys.c");
|
||||
//---------------------------------------------------------------------------
|
||||
This file is used by the project manager only and should be treated like the project file
|
||||
|
||||
|
||||
main
|
||||
|
|
@ -1,84 +0,0 @@
|
|||
<?xml version='1.0' encoding='utf-8' ?>
|
||||
<!-- C++Builder XML Project -->
|
||||
<PROJECT>
|
||||
<MACROS>
|
||||
<VERSION value="BCB.05.03"/>
|
||||
<PROJECT value="seqcon.exe"/>
|
||||
<OBJFILES value="tseqcon.obj ..\lib\io.obj ..\lib\morsys.obj"/>
|
||||
<RESFILES value=""/>
|
||||
<DEFFILE value=""/>
|
||||
<RESDEPEN value="$(RESFILES)"/>
|
||||
<LIBFILES value=""/>
|
||||
<LIBRARIES value=""/>
|
||||
<SPARELIBS value=""/>
|
||||
<PACKAGES value="Vcl50.bpi Vclx50.bpi bcbsmp50.bpi dclocx50.bpi bcb2kaxserver50.bpi"/>
|
||||
<PATHCPP value=".;..\lib"/>
|
||||
<PATHPAS value=".;"/>
|
||||
<PATHRC value=".;"/>
|
||||
<PATHASM value=".;"/>
|
||||
<DEBUGLIBPATH value="$(BCB)\lib\debug"/>
|
||||
<RELEASELIBPATH value="$(BCB)\lib\release"/>
|
||||
<LINKER value="tlink32"/>
|
||||
<USERDEFINES value="_DEBUG"/>
|
||||
<SYSDEFINES value="NO_STRICT;_NO_VCL;_RTLDLL;USEPACKAGES"/>
|
||||
<MAINSOURCE value="seqcon.bpf"/>
|
||||
<INCLUDEPATH value="..\lib;$(BCB)\include;$(BCB)\include\vcl"/>
|
||||
<LIBPATH value="..\lib;$(BCB)\lib\obj;$(BCB)\lib"/>
|
||||
<WARNINGS value="-w-par"/>
|
||||
</MACROS>
|
||||
<OPTIONS>
|
||||
<CFLAG1 value="-Od -H=$(BCB)\lib\vcl50.csm -Hc -Vx -Ve -X- -r- -pr -a8 -b- -k -y -v -vi-
|
||||
-tWC -tWM- -c"/>
|
||||
<PFLAGS value="-$YD -$W -$O- -v -JPHNE -M"/>
|
||||
<RFLAGS value=""/>
|
||||
<AFLAGS value="/mx /w2 /zd"/>
|
||||
<LFLAGS value="-D"" -ap -Tpe -x -Gn -v"/>
|
||||
</OPTIONS>
|
||||
<LINKER>
|
||||
<ALLOBJ value="c0x32.obj $(PACKAGES) $(OBJFILES)"/>
|
||||
<ALLRES value="$(RESFILES)"/>
|
||||
<ALLLIB value="$(LIBFILES) $(LIBRARIES) import32.lib cw32i.lib"/>
|
||||
</LINKER>
|
||||
<IDEOPTIONS>
|
||||
[Version Info]
|
||||
IncludeVerInfo=0
|
||||
AutoIncBuild=0
|
||||
MajorVer=1
|
||||
MinorVer=0
|
||||
Release=0
|
||||
Build=0
|
||||
Debug=0
|
||||
PreRelease=0
|
||||
Special=0
|
||||
Private=0
|
||||
DLL=0
|
||||
Locale=1031
|
||||
CodePage=1252
|
||||
|
||||
[Version Info Keys]
|
||||
CompanyName=
|
||||
FileDescription=
|
||||
FileVersion=1.0.0.0
|
||||
InternalName=
|
||||
LegalCopyright=
|
||||
LegalTrademarks=
|
||||
OriginalFilename=
|
||||
ProductName=
|
||||
ProductVersion=1.0.0.0
|
||||
Comments=
|
||||
|
||||
[Debugging]
|
||||
DebugSourceDirs=$(BCB)\source\vcl
|
||||
|
||||
[Parameters]
|
||||
RunParams=
|
||||
HostApplication=
|
||||
RemoteHost=
|
||||
RemotePath=
|
||||
RemoteDebug=0
|
||||
|
||||
[Compiler]
|
||||
ShowInfoMsgs=0
|
||||
LinkDebugVcl=0
|
||||
</IDEOPTIONS>
|
||||
</PROJECT>
|
||||
|
|
@ -1,8 +1,5 @@
|
|||
# the Ackermann function
|
||||
|
||||
import
|
||||
io
|
||||
|
||||
proc ack(x, y: int): int =
|
||||
if x != 0:
|
||||
if y != 0:
|
||||
|
|
|
|||
|
|
@ -1,13 +1,8 @@
|
|||
# simple check for one dimensional arrays
|
||||
|
||||
import
|
||||
io
|
||||
|
||||
type
|
||||
TMyArray = array[0..2, int]
|
||||
TMyRecord = record
|
||||
x, y: int
|
||||
|
||||
TMyRecord = tuple[x, y: int]
|
||||
|
||||
proc sum(a: TMyarray): int =
|
||||
result = 0
|
||||
|
|
|
|||
|
|
@ -1,8 +1,5 @@
|
|||
# test assert and exception handling
|
||||
|
||||
import
|
||||
io
|
||||
|
||||
proc callB() = assert(False)
|
||||
proc callA() = callB()
|
||||
proc callC() = callA()
|
||||
|
|
@ -10,10 +7,10 @@ proc callC() = callA()
|
|||
try:
|
||||
callC()
|
||||
except EAssertionFailed:
|
||||
io.write(stdout, "assertion failure!\n")
|
||||
write(stdout, "assertion failure!\n")
|
||||
except:
|
||||
io.write(stdout, "unknown exception!\n")
|
||||
write(stdout, "unknown exception!\n")
|
||||
finally:
|
||||
io.write(stdout, "this shall be always written\n")
|
||||
system.write(stdout, "this shall be always written\n")
|
||||
|
||||
assert(false)
|
||||
|
|
|
|||
|
|
@ -1,10 +1,7 @@
|
|||
# Test the assignment operator for complex types which need RTTI
|
||||
|
||||
import
|
||||
io
|
||||
|
||||
type
|
||||
TRec = record
|
||||
TRec = object
|
||||
x, y: int
|
||||
s: string
|
||||
seq: seq[string]
|
||||
|
|
@ -19,15 +16,15 @@ proc test() =
|
|||
a.s = "Hallo!"
|
||||
a.seq = ["abc", "def", "ghi", "jkl"]
|
||||
a.arr = []
|
||||
setLength(a.arr, 4)
|
||||
setLen(a.arr, 4)
|
||||
a.arr[0] = []
|
||||
a.arr[1] = []
|
||||
|
||||
b = a # perform a deep copy here!
|
||||
b.seq = ["xyz", "huch", "was", "soll"]
|
||||
writeln(stdout, length(a.seq))
|
||||
writeln(stdout, len(a.seq))
|
||||
writeln(stdout, a.seq[3])
|
||||
writeln(stdout, length(b.seq))
|
||||
writeln(stdout, len(b.seq))
|
||||
writeln(stdout, b.seq[3])
|
||||
writeln(stdout, b.y)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,9 +1,6 @@
|
|||
# check for forward label and
|
||||
# for failure when label is not declared
|
||||
|
||||
import
|
||||
io
|
||||
|
||||
proc main =
|
||||
block endLess:
|
||||
break endLess
|
||||
|
|
|
|||
|
|
@ -1,14 +1,12 @@
|
|||
# Test array, record constructors
|
||||
|
||||
import
|
||||
io
|
||||
|
||||
type
|
||||
TComplexRecord = record
|
||||
s: string
|
||||
x, y: int
|
||||
z: float
|
||||
TComplexRecord = tuple[
|
||||
s: string,
|
||||
x, y: int,
|
||||
z: float,
|
||||
chars: set[Char]
|
||||
]
|
||||
|
||||
proc testSem =
|
||||
var
|
||||
|
|
|
|||
|
|
@ -1,11 +1,12 @@
|
|||
# Test array, record constructors
|
||||
|
||||
type
|
||||
TComplexRecord = record
|
||||
s: string
|
||||
x, y: int
|
||||
z: float
|
||||
chars: set[char]
|
||||
TComplexRecord = tuple[
|
||||
s: string,
|
||||
x, y: int,
|
||||
z: float,
|
||||
chars: set[char],
|
||||
]
|
||||
|
||||
const
|
||||
things: array [0.., TComplexRecord] = [
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
# tests the copy proc
|
||||
|
||||
import
|
||||
strutils, io
|
||||
strutils
|
||||
|
||||
proc main() =
|
||||
const
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
# Tests the new format proc (including the & and &= operators)
|
||||
|
||||
import strutils, io
|
||||
import strutils
|
||||
|
||||
echo("Hi $1! How do you feel, $2?\n" % ["Andreas", "Rumpf"])
|
||||
#OUT Hi Andreas! How do you feel, Rumpf?
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
type
|
||||
PSym = ref TSym
|
||||
|
||||
TSym = record
|
||||
TSym = object
|
||||
next: PSym
|
||||
|
||||
var s: PSym
|
||||
|
|
|
|||
|
|
@ -6,14 +6,14 @@
|
|||
when defined(windows):
|
||||
type
|
||||
PSDL_semaphore = ptr TSDL_semaphore
|
||||
TSDL_semaphore = record
|
||||
TSDL_semaphore {.final.} = object
|
||||
id: uint32
|
||||
count: UInt32
|
||||
|
||||
elif defined(linux):
|
||||
type
|
||||
PSDL_semaphore = ptr TSDL_semaphore
|
||||
TSDL_semaphore = record
|
||||
TSDL_semaphore {.final.} = object
|
||||
sem: Pointer #PSem_t;
|
||||
when not defined(USE_NAMED_SEMAPHORES):
|
||||
sem_data: int
|
||||
|
|
|
|||
|
|
@ -1,96 +0,0 @@
|
|||
struct vector3d
|
||||
{
|
||||
float V[3];
|
||||
inline float Evaluate( const int I ) const { return V[I]; }
|
||||
|
||||
template< class ta >
|
||||
inline const vector3d& operator = ( const ta& Exp )
|
||||
{
|
||||
V[0] = Exp.Evaluate( 0 );
|
||||
V[1] = Exp.Evaluate( 1 );
|
||||
V[2] = Exp.Evaluate( 2 );
|
||||
}
|
||||
};
|
||||
|
||||
type
|
||||
TVector3D = record
|
||||
v: array [0..2, float]
|
||||
|
||||
TSum[A, B] = record
|
||||
TVecExpr2[A, B, op] = record
|
||||
|
||||
proc eval(a: TVector3d, i: int): float = a.v[i]
|
||||
proc eval[T, S](a: T, b: S, i: int): float = eval(a, i) + eval(b, i)
|
||||
|
||||
proc `+` [T, S](a, b: TVector3d): TSum[T, S] = return vecExpr2[a, b, TSum]
|
||||
|
||||
proc `=` [T](a: var TVector3d, b: T) =
|
||||
a.v[0] = eval(b, 0)
|
||||
a.v[1] = eval(b, 1)
|
||||
a.v[2] = eval(b, 2)
|
||||
|
||||
macro `=` (a: var TVector3d, b: expr) =
|
||||
|
||||
proc doSomething(a, b: TVector3d): TVector3d =
|
||||
eliminateTemps:
|
||||
result = a +^ b +^ a *^ a *^ 7
|
||||
# result = a
|
||||
# result +^= b
|
||||
# tmp = a
|
||||
# tmp *^= a
|
||||
# tmp *^= 7
|
||||
# result +^= tmp
|
||||
|
||||
macro vectorOptimizeExpr(n: expr): stmt =
|
||||
# load the expr n[1] into n[0]
|
||||
var e = n[1]
|
||||
if binOp(e) and Operator(e) == "+^":
|
||||
var m = flattenTree(n[1])
|
||||
result = newAst(nkStmtList) # ``newAst`` is built-in for any macro
|
||||
add(result, newAst(nkAsgn, n[0], m[1]))
|
||||
var tmp: PNode = nil
|
||||
for i in 2..m.len-1:
|
||||
if BinOp(m[i]):
|
||||
if tmp = nil: tmp = getTemp() # reuse temporary if possible
|
||||
vectorOptimizeExpr(newAst(nkAsgn, tmp, m[i]))
|
||||
add(result, newAst(nkCall, Operator(m) & "=", n[0], tmp))
|
||||
else:
|
||||
add(result, newAst(nkCall, Operator(m) & "=", n[0], m[i]))
|
||||
|
||||
macro eliminateTemps(s) {.check.} =
|
||||
case s.kind
|
||||
of nkAsgnStmt:
|
||||
result = vectorOptimizeExpr(s)
|
||||
else:
|
||||
result = s
|
||||
for i in 0..s.sons.len-1: result[i] = eliminateTemps(s[i])
|
||||
|
||||
struct sum
|
||||
{
|
||||
template< class ta, class tb >
|
||||
static inline float Evaluate( const int I, const ta& A, const tb& B )
|
||||
{ return A.Evaluate( I ) + B.Evaluate( I ); }
|
||||
};
|
||||
|
||||
|
||||
|
||||
template< class ta_a, class ta_b, class ta_eval >
|
||||
class vecexp_2
|
||||
{
|
||||
const ta_a Arg1;
|
||||
const ta_b Arg2;
|
||||
|
||||
public:
|
||||
inline vecexp_2( const ta_a& A1, const ta_b& A2 )
|
||||
: Arg1( A1 ), Arg2( A2 ) {}
|
||||
inline const float Evaluate ( const int I ) const
|
||||
{ return ta_eval::Evaluate( I, Arg1, Arg2 ); }
|
||||
};
|
||||
|
||||
|
||||
template< class ta, class tb > inline
|
||||
vecexp_2< ta, tb, sum >
|
||||
inline operator + ( const ta& A, const tb& B )
|
||||
{
|
||||
return vecexp_2< const ta, const tb, sum >( A, B );
|
||||
}
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
digraph thallo {
|
||||
times -> strutils;
|
||||
os -> strutils;
|
||||
os -> times;
|
||||
thallo -> os;
|
||||
}
|
||||
|
|
@ -11,9 +11,28 @@ proc fac[T](x: T): T =
|
|||
if x <= 1: return 1
|
||||
else: return x * fac(x-1)
|
||||
|
||||
macro macrotest(n: expr): stmt =
|
||||
expectKind(n, nnkCall)
|
||||
expectMinLen(n, 2)
|
||||
result = newNimNode(nnkStmtList, n)
|
||||
for i in 2..n.len-1:
|
||||
result.add(newCall("write", n[1], n[i]))
|
||||
result.add(newCall("writeln", n[1], newStrLitNode("")))
|
||||
|
||||
macro debug(n: expr): stmt =
|
||||
result = newNimNode(nnkStmtList, n)
|
||||
for i in 1..n.len-1:
|
||||
result.add(newCall("write", newIdentNode("stdout"), toStrLit(n[i])))
|
||||
result.add(newCall("write", newIdentNode("stdout"), newStrLitNode(": ")))
|
||||
result.add(newCall("writeln", newIdentNode("stdout"), n[i]))
|
||||
|
||||
macrotest(stdout, "finally", 4, 5, "variable", "argument lists")
|
||||
macrotest(stdout)
|
||||
|
||||
#GC_disable()
|
||||
|
||||
echo("This was compiled by Nimrod version " & system.nimrodVersion)
|
||||
writeln(stdout, "Hallo", " World", "!")
|
||||
|
||||
echo(["a", "b", "c", "d"].len)
|
||||
for x in items(["What's", "your", "name", "?"]):
|
||||
|
|
@ -21,6 +40,13 @@ for x in items(["What's", "your", "name", "?"]):
|
|||
var `name` = readLine(stdin)
|
||||
{.breakpoint.}
|
||||
echo("Hi " & thallo.name & "!\n")
|
||||
debug(name)
|
||||
|
||||
var testseq: seq[string] = [ "a", "b", "c", "d"]
|
||||
echo(repr(testseq))
|
||||
|
||||
var dummy = "hallo"
|
||||
echo(copy(dummy, 2, 3))
|
||||
|
||||
for i in 2..6:
|
||||
for j in countdown(i+4, 2):
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
# test illegal recursive types
|
||||
|
||||
type
|
||||
TLegal = record
|
||||
TLegal {.final.} = object
|
||||
x: int
|
||||
kids: seq[TLegal]
|
||||
|
||||
TIllegal = record
|
||||
TIllegal {.final.} = object
|
||||
y: Int
|
||||
x: array[0..3, TIllegal]
|
||||
#ERROR_MSG illegal recursion in type 'TIllegal'
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
# Test the new init section in modules
|
||||
|
||||
import minit, io
|
||||
import minit
|
||||
|
||||
write(stdout, "Hallo from main module!\n")
|
||||
#OUT Hallo from module! Hallo from main module!
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
# Test in out checking for parameters
|
||||
|
||||
proc abc(x: out int) =
|
||||
proc abc(x: var int) =
|
||||
x = 0
|
||||
|
||||
proc b() =
|
||||
|
|
|
|||
|
|
@ -1,10 +1,7 @@
|
|||
# test the file-IO
|
||||
|
||||
import
|
||||
io
|
||||
|
||||
proc main() =
|
||||
for line in lines("thallo.mor"):
|
||||
for line in lines("thallo.nim"):
|
||||
writeln(stdout, line)
|
||||
|
||||
main()
|
||||
|
|
|
|||
|
|
@ -1,8 +1,5 @@
|
|||
# Test the new iterators
|
||||
|
||||
import
|
||||
io
|
||||
|
||||
iterator xrange(fromm, to: int, step = 1): (a: int) =
|
||||
a = fromm
|
||||
while a <= to:
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
# test the new LastModificationTime() proc
|
||||
|
||||
import
|
||||
io, os, times
|
||||
os, times
|
||||
|
||||
proc main() =
|
||||
var
|
||||
|
|
|
|||
|
|
@ -1,8 +1,5 @@
|
|||
# Test nested loops and some other things
|
||||
|
||||
import
|
||||
io
|
||||
|
||||
proc andTest() =
|
||||
var a = 0 == 5 and 6 == 6
|
||||
|
||||
|
|
@ -60,7 +57,7 @@ proc Foo(n: int): int =
|
|||
while b:
|
||||
a = a + 3
|
||||
a = a + 5
|
||||
io.write(stdout, "Hallo!")
|
||||
write(stdout, "Hallo!")
|
||||
|
||||
|
||||
# We should come till here :-)
|
||||
|
|
|
|||
|
|
@ -1,8 +1,5 @@
|
|||
# Test the magic low() and high() procs
|
||||
|
||||
import
|
||||
io
|
||||
|
||||
type
|
||||
myEnum = enum e1, e2, e3, e4, e5
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,5 @@
|
|||
# tests for the interpreter
|
||||
|
||||
import
|
||||
io
|
||||
|
||||
proc loops(a: out int) =
|
||||
nil
|
||||
#var
|
||||
|
|
|
|||
|
|
@ -1,8 +1,5 @@
|
|||
# test nested ifs
|
||||
|
||||
import
|
||||
io
|
||||
|
||||
var
|
||||
x, y: int
|
||||
x = 2
|
||||
|
|
|
|||
|
|
@ -1,10 +0,0 @@
|
|||
USEUNIT("tnew.c");
|
||||
USEUNIT("..\lib\io.c");
|
||||
USEUNIT("..\lib\markstck.c");
|
||||
USEUNIT("..\lib\morsys.c");
|
||||
USEUNIT("..\lib\dlmalloc.c");
|
||||
//---------------------------------------------------------------------------
|
||||
This file is used by the project manager only and should be treated like the project file
|
||||
|
||||
|
||||
main
|
||||
|
|
@ -1,84 +0,0 @@
|
|||
<?xml version='1.0' encoding='utf-8' ?>
|
||||
<!-- C++Builder XML Project -->
|
||||
<PROJECT>
|
||||
<MACROS>
|
||||
<VERSION value="BCB.05.03"/>
|
||||
<PROJECT value="tnew.exe"/>
|
||||
<OBJFILES value="tnew.obj ..\lib\io.obj ..\lib\markstck.obj ..\lib\morsys.obj
|
||||
..\lib\dlmalloc.obj"/>
|
||||
<RESFILES value=""/>
|
||||
<DEFFILE value=""/>
|
||||
<RESDEPEN value="$(RESFILES)"/>
|
||||
<LIBFILES value=""/>
|
||||
<LIBRARIES value=""/>
|
||||
<SPARELIBS value=""/>
|
||||
<PACKAGES value="Vcl50.bpi Vclx50.bpi bcbsmp50.bpi dclocx50.bpi bcb2kaxserver50.bpi"/>
|
||||
<PATHCPP value=".;..\lib"/>
|
||||
<PATHPAS value=".;"/>
|
||||
<PATHRC value=".;"/>
|
||||
<PATHASM value=".;"/>
|
||||
<DEBUGLIBPATH value="$(BCB)\lib\debug"/>
|
||||
<RELEASELIBPATH value="$(BCB)\lib\release"/>
|
||||
<LINKER value="tlink32"/>
|
||||
<USERDEFINES value="_DEBUG"/>
|
||||
<SYSDEFINES value="NO_STRICT;_NO_VCL;_RTLDLL;USEPACKAGES"/>
|
||||
<MAINSOURCE value="tnew.bpf"/>
|
||||
<INCLUDEPATH value="..\lib;$(BCB)\include;$(BCB)\include\vcl"/>
|
||||
<LIBPATH value="..\lib;$(BCB)\lib\obj;$(BCB)\lib"/>
|
||||
<WARNINGS value="-w-par"/>
|
||||
</MACROS>
|
||||
<OPTIONS>
|
||||
<CFLAG1 value="-Od -Vx -Ve -X- -r- -pr -a8 -b- -k -y -v -vi- -tWC -tWM- -c"/>
|
||||
<PFLAGS value="-$YD -$W -$O- -v -JPHNE -M"/>
|
||||
<RFLAGS value=""/>
|
||||
<AFLAGS value="/mx /w2 /zd"/>
|
||||
<LFLAGS value="-D"" -ap -Tpe -x -Gn -v"/>
|
||||
</OPTIONS>
|
||||
<LINKER>
|
||||
<ALLOBJ value="c0x32.obj $(PACKAGES) $(OBJFILES)"/>
|
||||
<ALLRES value="$(RESFILES)"/>
|
||||
<ALLLIB value="$(LIBFILES) $(LIBRARIES) import32.lib cw32i.lib"/>
|
||||
</LINKER>
|
||||
<IDEOPTIONS>
|
||||
[Version Info]
|
||||
IncludeVerInfo=0
|
||||
AutoIncBuild=0
|
||||
MajorVer=1
|
||||
MinorVer=0
|
||||
Release=0
|
||||
Build=0
|
||||
Debug=0
|
||||
PreRelease=0
|
||||
Special=0
|
||||
Private=0
|
||||
DLL=0
|
||||
Locale=1031
|
||||
CodePage=1252
|
||||
|
||||
[Version Info Keys]
|
||||
CompanyName=
|
||||
FileDescription=
|
||||
FileVersion=1.0.0.0
|
||||
InternalName=
|
||||
LegalCopyright=
|
||||
LegalTrademarks=
|
||||
OriginalFilename=
|
||||
ProductName=
|
||||
ProductVersion=1.0.0.0
|
||||
Comments=
|
||||
|
||||
[Debugging]
|
||||
DebugSourceDirs=$(BCB)\source\vcl
|
||||
|
||||
[Parameters]
|
||||
RunParams=
|
||||
HostApplication=
|
||||
RemoteHost=
|
||||
RemotePath=
|
||||
RemoteDebug=0
|
||||
|
||||
[Compiler]
|
||||
ShowInfoMsgs=0
|
||||
LinkDebugVcl=0
|
||||
</IDEOPTIONS>
|
||||
</PROJECT>
|
||||
|
|
@ -1,8 +1,5 @@
|
|||
# Tests the object implementation
|
||||
|
||||
import
|
||||
io
|
||||
|
||||
type
|
||||
TPoint2d = object
|
||||
x, y: int
|
||||
|
|
|
|||
|
|
@ -1,6 +1,3 @@
|
|||
import
|
||||
io
|
||||
|
||||
type
|
||||
TBase = object
|
||||
x, y: int
|
||||
|
|
|
|||
|
|
@ -1,8 +1,5 @@
|
|||
# Tests emc's ability to detect overflows
|
||||
|
||||
import
|
||||
io
|
||||
|
||||
{.push overflowChecks: on.}
|
||||
|
||||
var
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
# Test for overloading
|
||||
|
||||
type
|
||||
TNone {.export: "_NONE".} = record
|
||||
TNone {.export: "_NONE", final.} = object
|
||||
|
||||
proc
|
||||
TNone(a, b: int) = nil #ERROR_MSG attempt to redefine 'TNone'
|
||||
|
|
|
|||
|
|
@ -1,8 +1,5 @@
|
|||
# Test operator overloading
|
||||
|
||||
import
|
||||
io
|
||||
|
||||
proc % (a, b: int): int =
|
||||
return a mod b
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +1,8 @@
|
|||
# this tests the new overflow literals
|
||||
|
||||
import
|
||||
io
|
||||
|
||||
var
|
||||
i: int
|
||||
i = cast[int](0xffffffff)
|
||||
i = int(0xffffffff)
|
||||
when defined(cpu64):
|
||||
if i == 4294967295:
|
||||
write(stdout, "works!\n")
|
||||
|
|
|
|||
|
|
@ -1,8 +1,5 @@
|
|||
# test this particular function
|
||||
|
||||
import
|
||||
io
|
||||
|
||||
proc mypos(sub, s: string, start: int = 0): int =
|
||||
var
|
||||
i, j, M, N: int
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
# Test the features that used to belong to the preprocessor
|
||||
|
||||
import
|
||||
io, times
|
||||
times
|
||||
|
||||
{.warning: "This is only a test warning!".}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,5 @@
|
|||
# test variables of type proc
|
||||
|
||||
import
|
||||
io
|
||||
|
||||
var
|
||||
x: proc (a, b: int): int {.cdecl.}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,5 @@
|
|||
# test the new pragmas
|
||||
|
||||
import
|
||||
io
|
||||
|
||||
{.push warnings: off, hints: off.}
|
||||
proc noWarning() =
|
||||
var
|
||||
|
|
|
|||
|
|
@ -1,8 +1,5 @@
|
|||
# Test the new beforeQuit variable:
|
||||
|
||||
import
|
||||
io
|
||||
|
||||
proc myExit() {.noconv.} =
|
||||
write(stdout, "just exiting...\n")
|
||||
|
||||
|
|
|
|||
|
|
@ -1,9 +1,6 @@
|
|||
# test the improved readline handling that does not care whether its
|
||||
# Macintosh, Unix or Windows text format.
|
||||
|
||||
import
|
||||
io
|
||||
|
||||
var
|
||||
inp: tTextFile
|
||||
line: string
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ type
|
|||
TA = array [0..2, PA]
|
||||
|
||||
PRec = ref TRec
|
||||
TRec = record
|
||||
TRec {.final.} = object
|
||||
a, b: TA
|
||||
|
||||
P1 = ref T1
|
||||
|
|
|
|||
|
|
@ -1,8 +1,5 @@
|
|||
# test for ref types (including refs to procs)
|
||||
|
||||
import
|
||||
io
|
||||
|
||||
type
|
||||
TProc = proc (a, b: int): int {.stdcall.}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
# which is based on the PCRE library
|
||||
|
||||
import
|
||||
regexprs, io
|
||||
regexprs
|
||||
|
||||
if "Username" =~ "[A-Za-z]+":
|
||||
echo("Yes!")
|
||||
|
|
|
|||
|
|
@ -1,9 +1,6 @@
|
|||
# Test the register usage of the virtual machine and
|
||||
# the blocks in var statements
|
||||
|
||||
import
|
||||
io
|
||||
|
||||
proc main(a, b: int) =
|
||||
var x = 0
|
||||
write(stdout, x)
|
||||
|
|
|
|||
|
|
@ -1,10 +1,7 @@
|
|||
# test the new "repr" built-in proc
|
||||
|
||||
import
|
||||
io
|
||||
|
||||
type
|
||||
TPoint = record
|
||||
TPoint {.final.} = object
|
||||
x, y, z: int
|
||||
s: array [0..1, string]
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +1,7 @@
|
|||
# Test the &= operator for sequences and strings
|
||||
|
||||
import
|
||||
io
|
||||
|
||||
type
|
||||
TRec = record
|
||||
TRec {.final.} = object
|
||||
x, y: int
|
||||
s: string
|
||||
seq: seq[string]
|
||||
|
|
|
|||
|
|
@ -1,10 +1,7 @@
|
|||
# Test the sizeof proc
|
||||
|
||||
import
|
||||
io
|
||||
|
||||
type
|
||||
TMyRecord = record
|
||||
TMyRecord {.final.} = object
|
||||
x, y: int
|
||||
b: bool
|
||||
r: float
|
||||
|
|
|
|||
|
|
@ -4,12 +4,11 @@ var
|
|||
x = [0, 1, 2]
|
||||
|
||||
type
|
||||
TStringDesc = record
|
||||
TStringDesc {.final.} = object
|
||||
len, space: int # len and space without counting the terminating zero
|
||||
data: array [0..0, char] # for the '\0' character
|
||||
|
||||
var
|
||||
emptyString {.export: "emptyString".}: TStringDesc = (
|
||||
len: 0, space: 0, data: ['\0']
|
||||
)
|
||||
emptyString {.export: "emptyString".}: TStringDesc
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,5 @@
|
|||
# compute the edit distance between two strings
|
||||
|
||||
import
|
||||
io
|
||||
|
||||
proc editDistance(a, b: string): int =
|
||||
var c: seq[int] = []
|
||||
var
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
# test the new strutils module
|
||||
|
||||
import
|
||||
strutils, io
|
||||
strutils
|
||||
|
||||
proc testStrip() =
|
||||
write(stdout, strip(" ha "))
|
||||
|
|
|
|||
|
|
@ -1,16 +1,16 @@
|
|||
# Test various aspects
|
||||
|
||||
import
|
||||
mvarious, io
|
||||
mvarious
|
||||
|
||||
type
|
||||
PA = ref TA
|
||||
PB = ref TB
|
||||
|
||||
TB = record
|
||||
TB = object
|
||||
a: PA
|
||||
|
||||
TA = record
|
||||
TA = object
|
||||
b: TB
|
||||
x: int
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
# Test variable length binary integers
|
||||
|
||||
import
|
||||
io, strutils
|
||||
strutils
|
||||
|
||||
type
|
||||
TBuffer = array [0..10, int8]
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
# iterate over all files with a given filter:
|
||||
|
||||
import
|
||||
io, os, times
|
||||
os, times
|
||||
|
||||
proc main(filter: string) =
|
||||
for filename in walkFiles(filter):
|
||||
|
|
@ -10,4 +10,4 @@ proc main(filter: string) =
|
|||
for key, val in iterOverEnvironment():
|
||||
writeln(stdout, key & '=' & val)
|
||||
|
||||
main("*.mor")
|
||||
main("*.nim")
|
||||
|
|
|
|||
|
|
@ -1,13 +0,0 @@
|
|||
USEUNIT("twalker.c");
|
||||
USEUNIT("..\lib\morlib.c");
|
||||
USEUNIT("..\lib\os.c");
|
||||
USEUNIT("..\lib\refcgc.c");
|
||||
USEUNIT("..\lib\strutils.c");
|
||||
USEUNIT("..\lib\time.c");
|
||||
USEUNIT("..\lib\io.c");
|
||||
USEUNIT("..\lib\morbase.c");
|
||||
//---------------------------------------------------------------------------
|
||||
This file is used by the project manager only and should be treated like the project file
|
||||
|
||||
|
||||
main
|
||||
102
tests/walker.bpr
102
tests/walker.bpr
|
|
@ -1,102 +0,0 @@
|
|||
<?xml version='1.0' encoding='utf-8' ?>
|
||||
<!-- C++Builder XML Project -->
|
||||
<PROJECT>
|
||||
<MACROS>
|
||||
<VERSION value="BCB.05.03"/>
|
||||
<PROJECT value="walker.exe"/>
|
||||
<OBJFILES value="twalker.obj ..\lib\morlib.obj ..\lib\os.obj ..\lib\refcgc.obj
|
||||
..\lib\strutils.obj ..\lib\time.obj ..\lib\io.obj ..\lib\morbase.obj"/>
|
||||
<RESFILES value=""/>
|
||||
<DEFFILE value=""/>
|
||||
<RESDEPEN value="$(RESFILES)"/>
|
||||
<LIBFILES value=""/>
|
||||
<LIBRARIES value=""/>
|
||||
<SPARELIBS value=""/>
|
||||
<PACKAGES value="Vcl50.bpi Vclx50.bpi bcbsmp50.bpi dclocx50.bpi bcb2kaxserver50.bpi"/>
|
||||
<PATHCPP value=".;..\lib"/>
|
||||
<PATHPAS value=".;"/>
|
||||
<PATHRC value=".;"/>
|
||||
<PATHASM value=".;"/>
|
||||
<DEBUGLIBPATH value="$(BCB)\lib\debug"/>
|
||||
<RELEASELIBPATH value="$(BCB)\lib\release"/>
|
||||
<LINKER value="tlink32"/>
|
||||
<USERDEFINES value="_DEBUG"/>
|
||||
<SYSDEFINES value="NO_STRICT;_NO_VCL;_RTLDLL;USEPACKAGES"/>
|
||||
<MAINSOURCE value="walker.bpf"/>
|
||||
<INCLUDEPATH value="..\lib;$(BCB)\include;$(BCB)\include\vcl"/>
|
||||
<LIBPATH value="..\lib;$(BCB)\lib\obj;$(BCB)\lib"/>
|
||||
<WARNINGS value="-w-par"/>
|
||||
</MACROS>
|
||||
<OPTIONS>
|
||||
<CFLAG1 value="-Od -H=$(BCB)\lib\vcl50.csm -Hc -Vx -Ve -X- -r- -a8 -b- -k -y -v -vi- -tWC
|
||||
-tWM- -c"/>
|
||||
<PFLAGS value="-$YD -$W -$O- -v -JPHNE -M"/>
|
||||
<RFLAGS value=""/>
|
||||
<AFLAGS value="/mx /w2 /zd"/>
|
||||
<LFLAGS value="-D"" -ap -Tpe -x -Gn -v"/>
|
||||
</OPTIONS>
|
||||
<LINKER>
|
||||
<ALLOBJ value="c0x32.obj $(PACKAGES) $(OBJFILES)"/>
|
||||
<ALLRES value="$(RESFILES)"/>
|
||||
<ALLLIB value="$(LIBFILES) $(LIBRARIES) import32.lib cw32i.lib"/>
|
||||
</LINKER>
|
||||
<IDEOPTIONS>
|
||||
[Version Info]
|
||||
IncludeVerInfo=0
|
||||
AutoIncBuild=0
|
||||
MajorVer=1
|
||||
MinorVer=0
|
||||
Release=0
|
||||
Build=0
|
||||
Debug=0
|
||||
PreRelease=0
|
||||
Special=0
|
||||
Private=0
|
||||
DLL=0
|
||||
Locale=1031
|
||||
CodePage=1252
|
||||
|
||||
[Version Info Keys]
|
||||
CompanyName=
|
||||
FileDescription=
|
||||
FileVersion=1.0.0.0
|
||||
InternalName=
|
||||
LegalCopyright=
|
||||
LegalTrademarks=
|
||||
OriginalFilename=
|
||||
ProductName=
|
||||
ProductVersion=1.0.0.0
|
||||
Comments=
|
||||
|
||||
[HistoryLists\hlIncludePath]
|
||||
Count=2
|
||||
Item0=..\lib;$(BCB)\include;$(BCB)\include\vcl;C:\Eigenes\morpork\lib
|
||||
Item1=..\lib;$(BCB)\include;$(BCB)\include\vcl
|
||||
|
||||
[HistoryLists\hlLibraryPath]
|
||||
Count=1
|
||||
Item0=..\lib;$(BCB)\lib\obj;$(BCB)\lib
|
||||
|
||||
[HistoryLists\hlDebugSourcePath]
|
||||
Count=1
|
||||
Item0=$(BCB)\source\vcl
|
||||
|
||||
[HistoryLists\hlConditionals]
|
||||
Count=1
|
||||
Item0=_DEBUG
|
||||
|
||||
[Debugging]
|
||||
DebugSourceDirs=$(BCB)\source\vcl
|
||||
|
||||
[Parameters]
|
||||
RunParams=
|
||||
HostApplication=
|
||||
RemoteHost=
|
||||
RemotePath=
|
||||
RemoteDebug=0
|
||||
|
||||
[Compiler]
|
||||
ShowInfoMsgs=0
|
||||
LinkDebugVcl=0
|
||||
</IDEOPTIONS>
|
||||
</PROJECT>
|
||||
Loading…
Add table
Add a link
Reference in a new issue