Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(559)

Unified Diff: vm/dart_api_impl_test.cc

Issue 10186008: Move the dart API benchmark to the VM benchmark infrastructure so that it will get run as part of r… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « vm/benchmark_test.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: vm/dart_api_impl_test.cc
===================================================================
--- vm/dart_api_impl_test.cc (revision 6846)
+++ vm/dart_api_impl_test.cc (working copy)
@@ -4542,111 +4542,6 @@
Isolate::SetInterruptCallback(saved);
}
-
-void InitNativeFields(Dart_NativeArguments args) {
- Dart_EnterScope();
- int count = Dart_GetNativeArgumentCount(args);
- EXPECT_EQ(1, count);
-
- Dart_Handle recv = Dart_GetNativeArgument(args, 0);
- EXPECT(!Dart_IsError(recv));
- Dart_Handle result = Dart_SetNativeInstanceField(recv, 0, 7);
- EXPECT(!Dart_IsError(result));
-
- Dart_ExitScope();
-}
-
-
-// The specific api functions called here are a bit arbitrary. We are
-// trying to get a sense of the overhead for using the dart api.
-void UseDartApi(Dart_NativeArguments args) {
- Dart_EnterScope();
- int count = Dart_GetNativeArgumentCount(args);
- EXPECT_EQ(3, count);
-
- // Get the receiver.
- Dart_Handle recv = Dart_GetNativeArgument(args, 0);
- EXPECT(!Dart_IsError(recv));
-
- // Get param1.
- Dart_Handle param1 = Dart_GetNativeArgument(args, 1);
- EXPECT(!Dart_IsError(param1));
- EXPECT(Dart_IsInteger(param1));
- bool fits = false;
- Dart_Handle result = Dart_IntegerFitsIntoInt64(param1, &fits);
- EXPECT(!Dart_IsError(result) && fits);
- int64_t value1;
- result = Dart_IntegerToInt64(param1, &value1);
- EXPECT(!Dart_IsError(result));
- EXPECT_LE(0, value1);
- EXPECT_LE(value1, 1000000);
-
- // Get native field from receiver.
- intptr_t value2;
- result = Dart_GetNativeInstanceField(recv, 0, &value2);
- EXPECT(!Dart_IsError(result));
- EXPECT_EQ(7, value2);
-
- // Return param + receiver.field.
- Dart_SetReturnValue(args, Dart_NewInteger(value1 * value2));
- Dart_ExitScope();
-}
-
-
-static Dart_NativeFunction bm_uda_lookup(Dart_Handle name, int argument_count) {
- const char* cstr = NULL;
- Dart_Handle result = Dart_StringToCString(name, &cstr);
- EXPECT(!Dart_IsError(result));
- if (strcmp(cstr, "init") == 0) {
- return InitNativeFields;
- } else {
- return UseDartApi;
- }
-}
-
-
-TEST_CASE(Benchmark_UseDartApi) {
- const char* kScriptChars =
- "class Class extends NativeFieldsWrapper{\n"
- " int init() native 'init';\n"
- " int method(int param1, int param2) native 'method';\n"
- "}\n"
- "\n"
- "double benchmark(int count) {\n"
- " Class c = new Class();\n"
- " c.init();\n"
- " Stopwatch sw = new Stopwatch.start();\n"
- " for (int i = 0; i < count; i++) {\n"
- " c.method(i,7);\n"
- " }\n"
- " sw.stop();\n"
- " return sw.elapsedInUs() / count;\n"
- "}\n";
-
- Dart_Handle lib = TestCase::LoadTestScript(
- kScriptChars,
- reinterpret_cast<Dart_NativeEntryResolver>(bm_uda_lookup));
-
- // Create a native wrapper class with native fields.
- Dart_Handle result = Dart_CreateNativeWrapperClass(
- lib,
- Dart_NewString("NativeFieldsWrapper"),
- 1);
- EXPECT_VALID(result);
-
- Dart_Handle args[1];
- args[0] = Dart_NewInteger(100000);
- result = Dart_Invoke(lib,
- Dart_NewString("benchmark"),
- 1,
- args);
- EXPECT_VALID(result);
- EXPECT(Dart_IsDouble(result));
- double out;
- result = Dart_DoubleValue(result, &out);
- fprintf(stderr, "Benchmark_UseDartApi: %f us per iteration\n", out);
-}
-
#endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64).
} // namespace dart
« no previous file with comments | « vm/benchmark_test.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698