#include using namespace std; #include #include #include double now() { struct timeval tv; struct timezone tz; gettimeofday(&tv, &tz); return (double)tv.tv_sec + ((double)tv.tv_usec / 1000000.0); } int main(void) { cout << "Playing with embedded Ruby\n"; ruby_init(); double start = now(); for (int i = 0; i < 100; ++i) { int pid = fork(); if (pid == 0) { rb_eval_string("load '/home/phil/projects/ruby-cgi/test.rb'"); exit(0); } else { int status; waitpid(pid, &status, 0); } } double end = now(); cout << "100 runs of test.rb took " << (end-start) << " s; " << (100.0/(end-start)) << "/s\n"; }