runtime

How fast is D compared to C++?

左心房为你撑大大i 提交于 2019-11-29 18:41:23
I like some features of D, but would be interested if they come with a runtime penalty? To compare, I implemented a simple program that computes scalar products of many short vectors both in C++ and in D. The result is surprising: D: 18.9 s [see below for final runtime] C++: 3.8 s Is C++ really almost five times as fast or did I make a mistake in the D program? I compiled C++ with g++ -O3 (gcc-snapshot 2011-02-19) and D with dmd -O (dmd 2.052) on a moderate recent linux desktop. The results are reproducible over several runs and standard deviations negligible. Here the C++ program: #include

Spaces in java execute path for OS X

扶醉桌前 提交于 2019-11-29 18:31:12
问题 On OS X, I am trying to .exec something, but when a path contains a space, it doesn't work. I've tried surrounding the path with quotes, escaping the space, and even using \u0020. For example, this works: Runtime.getRuntime().exec("open /foldername/toast.sh"); But if there's a space, none of these work: Runtime.getRuntime().exec("open /folder name/toast.sh"); Runtime.getRuntime().exec("open \"/folder name/toast.sh\""); Runtime.getRuntime().exec("open /folder\\ name/toast.sh"); Runtime

Changing dataset connection string at runtime

南楼画角 提交于 2019-11-29 18:15:16
问题 I have a c# generated dataset. How can I change the connection string so I can use the dataset with another (identically structured yet differently populated) database? This has to occur at runtime as I do not know the server or database name at compile time. I am using c# 2.0. 回答1: You can modify a single instance of the table adapter. _myAdapter.Connection.ConnectionString = connectionString; 回答2: Based on the link above, I did it this way: partial class QueriesTableAdapter { public

dynamically create class in scala, should I use interpreter?

走远了吗. 提交于 2019-11-29 17:38:27
问题 I want to create a class at run-time in Scala . For now, just consider a simple case where I want to make the equivalent of a java bean with some attributes, I only know these attributes at run time. How can I create the scala class? I am willing to create from scala source file if there is a way to compile it and load it at run time, I may want to as I sometimes have some complex function I want to add to the class. How can I do it? I worry that the scala interpreter which I read about is

Multi language android app during Runtime?

橙三吉。 提交于 2019-11-29 17:25:22
My aim is to change an application language from English to Chinese during runtime, is there any suggestions? language_spinner = (Spinner)findViewById(R.id.settings_language_spinner); language_spinner.setOnItemSelectedListener(new OnItemSelectedListener() { public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) { if (pos == 1){ Toast.makeText(parent.getContext(),"You have selected English",Toast.LENGTH_SHORT).show(); setLocale("en"); }else if (pos == 2){ Toast.makeText(parent.getContext(),"You have selected Chinese",Toast.LENGTH_SHORT).show(); setLocale("zh"); } }

JDK 和 JRE 的区别?(skycto JEEditor)

ぐ巨炮叔叔 提交于 2019-11-29 17:23:05
原文链接: https://blog.csdn.net/meism5/... JRE:Java Runtime Environment(java运行时环境)。即java程序的运行时环境,包含了java虚拟机,java基础类库。 JDK:Java Development Kit(java开发工具包)。即java语言编写的程序所需的开发工具包。 JDK包含了JRE,同时还包括java源码的编译器javac、监控工具jconsole、分析工具jvisualvm等。 来源: https://www.cnblogs.com/skycto/p/11524307.html

What is the run time complexity O(?) for JavaScript to access an object property? [duplicate]

一世执手 提交于 2019-11-29 17:00:55
This question already has an answer here: Is there anything that guarantees constant time for accessing a property of an object in JavaScript? 1 answer var obj = {}; obj["A"] = true; obj["B"] = true; obj["C"] = true; console.log(obj["D"]); The above code will print "undefined". What is the runtime complexity when javascript is trying to access obj["D"] ? I guess it will be the same as it is trying to access obj["A"]? The reason why I am asking this is because I am comparing the efficiency between these two code: //Code 1 var x = ["a","b","c"]; var y = ["a","b","c"]; for(i = 0; i<x.length; i++)

Running other programs from Java

耗尽温柔 提交于 2019-11-29 16:18:37
I need to run a couple of other programs from my own Java program, basically I need to run these command line statements. svn log --xml -v > svn.log and java -jar example.jar arg1 arg2 and I need to use the text outputs written to the console from these programs in my own program. I've tried Runtime.getRuntime().exec() with the svn, but it doesn't seem to be doing anything because it doesn't make a svn.log file. Also both programs need to be called in different places, the svn line needs to be called from inside one folder and the java line needs to be called from another. Any ideas on how to

Create a class at runtime - Why do NSClassFromString AND objc_getclass return nil?

亡梦爱人 提交于 2019-11-29 15:47:34
问题 I've tried using both: NSClassFromString and objc_getclass to return a class, so I can create it at runtime, but both functions return nil for some classes, for example "TestClass". Note that NSClassFromString works for me for 99% of classes. If I add [TestClass class]; before I call NSStringFromClass or objc_getclass it, it works. and if I try to just create the class using a class reference, i.e.: [TestClass alloc]; it works too. So how can I force the class to load at runtime so

Runtime.addShutdownHook理解

怎甘沉沦 提交于 2019-11-29 15:35:12
一.Runtime.addShutdownHook理解 在看别人的代码时,发现其中有这个方法,便顺便梳理一下。 void java.lang.Runtime.addShutdownHook(Thread hook) 该方法用来在jvm中增加一个关闭的钩子。当程序正常退出,系统调用 System.exit方法或虚拟机被关闭时才会执行添加的shutdownHook线程。其中shutdownHook是一个已初始化但并不有启动的线 程,当jvm关闭的时候,会执行系统中已经设置的所有通过方法addShutdownHook添加的钩子,当系统执行完这些钩子后,jvm才会关闭。所以 可通过这些钩子在jvm关闭的时候进行内存清理、资源回收等工作。 二.示例代码 Java代码 public class TestRuntimeShutdownHook { public static void main(String[] args) { Thread shutdownHookOne = new Thread() { public void run() { System.out.println( "shutdownHook one..." ); } }; Runtime.getRuntime().addShutdownHook(shutdownHookOne); Runnable threadOne =