扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
作者:王玉磊编译 来源:Csdn 2007年8月31日
关键字:
NativeTest | |
Python |
Java |
from pynative import * for i in xrange(1000000): hello()
|
public class NativeTest { public native void nativeMethod(); static { System.loadLibrary("javanative"); } public static void main(String[] args) { NativeTest nt = new NativeTest(); for (int i = 0; i < 1000000; i++) { nt.nativeMethod(); } } } |
Python C Module |
Java C Module |
#include "Python.h"
static PyObject* pynative_hello(self,args) PyObject *self; PyObject *args; { printf("Hello, world!\n"); Py_INCREF(Py_None); return Py_None; }
static PyMethodDef NativeMethods[] = { {"hello", pynative_hello, METH_VARARGS}, {NULL, NULL}, /* Sentinel... what's this? */ };
void initpynative() { (void) Py_InitModule("pynative", NativeMethods); }
|
--- Autogenerated NativeTest.h --- /* DO NOT EDIT THIS FILE - it is machine generated */ #include /* Header for class NativeTest */
#ifndef _Included_NativeTest #define _Included_NativeTest
#pragma pack(4)
typedef struct ClassNativeTest { char PAD; /* ANSI C requires structures to have a least one member */ } ClassNativeTest; HandleTo(NativeTest);
#pragma pack()
#ifdef __cplusplus extern "C" { #endif extern void NativeTest_nativeMethod(struct HNativeTest *); #ifdef __cplusplus } #endif #endif ---
#include #include #include "NativeTest.h"
JNIEXPORT void JNICALL Java_NativeTest_nativeMethod(JNIEnv *env, jobject obj) { printf("Hello world!\n"); } |
NoTest | |
Python |
Java |
|
public class NoTest { public static void main(String[] args){} } |
ObjectTest | |
Python |
Java |
class ObjectTest: pass
for i in xrange(1000): root=ObjectTest() for j in xrange(10000): root.next=ObjectTest() root=root.next
|
public class ObjectTest { public ObjectTest next; public static void main(String[] args) { for (int i = 0; i < 1000; i++) { ObjectTest root = new ObjectTest(); for (int j = 0; j < 10000; j++) { root.next=new ObjectTest(); root=root.next; } } } } |
SpeedTest | |
Python |
Java |
for x in xrange(1000000): pass
|
public class SpeedTest { public static void main(String[] args) { for (int i = 0; i < 1000000; i++); } } |
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。
现场直击|2021世界人工智能大会
直击5G创新地带,就在2021MWC上海
5G已至 转型当时——服务提供商如何把握转型的绝佳时机
寻找自己的Flag
华为开发者大会2020(Cloud)- 科技行者