int main () { printf ("Results of mathlib_performance test:\n"); try { Environment env; Shell shell ("lua", env); xtl::com_ptr<IInterpreter> script (shell.Interpreter ()); env.Library ("global").Register ("typename", make_invoker (&get_typename)); env.BindLibraries ("Math"); load_script (*script, SCRIPT_FILE_NAME); printf ("Test c++ performance:\n"); size_t start_time = common::milliseconds (); float test_result = test (); printf ("Duration = %u ms, result = %f\n", common::milliseconds () - start_time, test_result); printf ("Test lua performance:\n"); start_time = common::milliseconds (); test_result = invoke<float> (*script, "test"); printf ("Duration = %u ms, result = %f\n", common::milliseconds () - start_time, test_result); } catch (xtl::bad_any_cast& exception) { printf ("%s: %s -> %s\n", exception.what (), exception.source_type ().name (), exception.target_type ().name ()); } catch (std::exception& exception) { printf ("exception: %s\n", exception.what ()); } return 0; }
int main () { printf ("Results of common_string_tree_test:\n"); try { common::LogFilter filter ("script.binds.*", &log_handler); Environment env; InvokerRegistry lib = env.CreateLibrary ("Utils"); lib.Register ("PrintIndent", make_invoker (&print_indent)); Shell shell ("lua", env); xtl::com_ptr<IInterpreter> script (shell.Interpreter ()); env.BindLibraries ("Common"); load_script (*script, SCRIPT_FILE_NAME); printf ("Test library:\n"); invoke<void> (*script, "test"); } catch (xtl::bad_any_cast& exception) { printf ("%s: %s -> %s\n", exception.what (), exception.source_type ().name (), exception.target_type ().name ()); } catch (std::exception& exception) { printf ("exception: %s\n", exception.what ()); } return 0; }