optimization

ResultSet: Retrieving column values by index versus retrieving by label

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-27 23:39:50
问题 When using JDBC, I often come across constructs like ResultSet rs = ps.executeQuery(); while (rs.next()) { int id = rs.getInt(1); // Some other actions } I asked myself (and authors of code too) why not to use labels for retrieving column values: int id = rs.getInt("CUSTOMER_ID"); The best explanation I've heard is something concerning performance. But actually, does it make processing extremely fast? I don't believe so, though I have never performed measurements. Even if retrieving by label

ResultSet: Retrieving column values by index versus retrieving by label

我们两清 提交于 2019-12-27 23:39:28
问题 When using JDBC, I often come across constructs like ResultSet rs = ps.executeQuery(); while (rs.next()) { int id = rs.getInt(1); // Some other actions } I asked myself (and authors of code too) why not to use labels for retrieving column values: int id = rs.getInt("CUSTOMER_ID"); The best explanation I've heard is something concerning performance. But actually, does it make processing extremely fast? I don't believe so, though I have never performed measurements. Even if retrieving by label

GCC C++ “Hello World” program -> .exe is 500kb big when compiled on Windows. How can I reduce its size?

╄→гoц情女王★ 提交于 2019-12-27 20:09:23
问题 I just recently started learning C++ - I am using nuwen's version of MingW on Windows, using NetBeans as an IDE (I have also MSDN AA Version of MSVC 2008, though I don't use it very often). When compiling this simple program: #include <iostream> using namespace std; int dog, cat, bird, fish; void f(int pet) { cout << "pet id number: " << pet << endl; } int main() { int i, j, k; cout << "f(): " << (long)&f << endl; cout << "dog: " << (long)&dog << endl; cout << "cat: " << (long)&cat << endl;

How can I speed up powershell to get firewall rules on windows 10?

瘦欲@ 提交于 2019-12-25 20:01:15
问题 I need to enumerate all firewall rules on windows 10 using PowerShell. I switched to PowerShell from netsh because some built-in rules were getting funny names like @{microsoft.windows.shellexperiencehost_10.0.17134.1_neutral_neutral_cw5n1h2txyewy?ms-resource://microsoft.windows.shellexperiencehost/resources/pkgdisplayname} which I was unable to manage with netsh . Switching to PowerShell shows that the real name was a UID and fixed my problem but the code is really slow to run: PS C:\Users

Knight's tour algorithm

邮差的信 提交于 2019-12-25 18:37:18
问题 So I have to write this algorithm (this version does not need to end in the same spot that knight started), and I got it to work, but it's too slow. It works with starting positions x=0 and y=0 for size=8, but if I try to manipulate x and y to for example 2 and 4 it doesn't end after a few minutes. Can anyone help? #include <stdio.h> #define size 8 int ruch_x[]={ -1, 1, -2, 2, -2, 2, -1, 1}; //arrays of possible knight moves, for example 2nd move is [1,2]// int ruch_y[]={ 2, 2, 1, 1, -1, -1,

Calculate tan having sin/cos LUT

做~自己de王妃 提交于 2019-12-25 18:16:06
问题 #define PARTPERDEGREE 1 double mysinlut[PARTPERDEGREE * 90 + 1]; double mycoslut[PARTPERDEGREE * 90 + 1]; void MySinCosCreate() { int i; double angle, angleinc; // Each degree also divided into 10 parts angleinc = (M_PI / 180) / PARTPERDEGREE; for (i = 0, angle = 0.0; i <= (PARTPERDEGREE * 90 + 1); ++i, angle += angleinc) { mysinlut[i] = sin(angle); } angleinc = (M_PI / 180) / PARTPERDEGREE; for (i = 0, angle = 0.0; i <= (PARTPERDEGREE * 90 + 1); ++i, angle += angleinc) { mycoslut[i] = cos

Optimization of FIS membership functions, via GA

一曲冷凌霜 提交于 2019-12-25 17:46:48
问题 i am trying to optimize my FIS with the help of a GA, with matlab optimization toolbox. The code looks like this: function errorr=fun3_2(x) Name='eleni'; Type='mamdani'; NumInputs='8'; NumOutputs='1'; % NumRules='80'; AndMethod='min'; OrMethod='max'; ImpMethod='min'; AggMethod='max'; DefuzzMethod='centroid'; a=newfis('eleni'); %INPUTS_______________input 1____________ a.input(1).name='ARIAS'; a.input(1).range=[0 1]; a.input(1).mf(1).name='1'; a.input(1).mf(1).type='trimf'; a.input(1).mf(1)

Reference Type Variable Declaration Inside a for Loop

南楼画角 提交于 2019-12-25 17:01:54
问题 Let we have a Student class. Form the following code snippet (Java) we know - Student aStudent = new Student(); A 'Student' type reference variable is created An object of 'Student' is created with the 'new Student()' The object is assigned with the reference variable 'aStudent' So far I know, each time we write 'new Student()' a new object is created and the newly created object is allocated a memory space. But sometimes we write something like this in a for loop - for ( int i=0; i<10000; i+

Reference Type Variable Declaration Inside a for Loop

走远了吗. 提交于 2019-12-25 17:01:22
问题 Let we have a Student class. Form the following code snippet (Java) we know - Student aStudent = new Student(); A 'Student' type reference variable is created An object of 'Student' is created with the 'new Student()' The object is assigned with the reference variable 'aStudent' So far I know, each time we write 'new Student()' a new object is created and the newly created object is allocated a memory space. But sometimes we write something like this in a for loop - for ( int i=0; i<10000; i+

Splitting up a list into different length parts under special condition

元气小坏坏 提交于 2019-12-25 16:01:25
问题 I need an algorithm of dividing different manufacturing parts in to uneven groups. The main condition is that difference between maximum number in the group and all others should be as low as possible. For example: if we have list [1,3,4,11,12,19,20,21] and we decide that it should be divided in 3 parts it should be divided into [1,3,4],[11,12],[19,20,21] . In the same case if we decide to divide it in to 4 we would get : [1,3,4],[11],[12],[19,20,21]. In order to clarify "difference between