2015年12月18日 星期五

C++ explicit call of operator new and delete



Below Code is equvalent:
  1.     {
  2.         A * a = new A;
  3.         delete a;
  4.     }
  5.     {
  6.         A * a = (A*)(::operator new(sizeof(A)));
  7.         a->A::A();
  8.         a->~A();
  9.         ::operator delete(a);
  10.     }

  1. #include <iostream>
  2. #include <list>
  3. #include <allocators>
  4. class A
  5. {
  6. public:
  7.     A(){std::cout << " A()\n";}
  8.     ~A(){std::cout << "~A()\n";}
  9. };
  10. int main()
  11. {
  12.     using namespace std;
  13.     {
  14.         A * a = new A;
  15.         delete a;
  16.     }
  17.     {
  18.         A * a = (A*)(::operator new(sizeof(A)));
  19.         a->A::A();
  20.         if (a!=0)
  21.         {
  22.             a->~A();
  23.             ::operator delete(a);
  24.         }
  25.     }
  26.     return 0;
  27. }

2015年11月20日 星期五

Windows Network Commands netstat






cmd.exe /c del /Q E:\Support\Result\* & netstat -abp UDP > E:\Support\Result\netstat-abpUDP.log & logoff
netstat -a -p UDP -b
  Proto  Local Address          Foreign Address        State
  UDP    0.0.0.0:123            *:*
 [ntpd.exe]
  UDP    0.0.0.0:161            *:*
 [snmp.exe]
  UDP    0.0.0.0:500            *:*
  IKEEXT
 [svchost.exe]
  UDP    0.0.0.0:4500           *:*
  IKEEXT
 [svchost.exe]
  UDP    0.0.0.0:5355           *:*
  Dnscache
 [svchost.exe]
  UDP    0.0.0.0:8000           *:*
 [MonitorService.exe]
  UDP    0.0.0.0:8903           *:*
 [FrameworkService.exe]
  UDP    0.0.0.0:49154          *:*
 [snmp.exe]
  UDP    0.0.0.0:57101          *:*
 [ntpq.exe]
  UDP    0.0.0.0:57106          *:*
 [MonitorService.exe]
  UDP    0.0.0.0:57107          *:*
 [MonitorService.exe]
  UDP    10.32.29.156:123       *:*
 [ntpd.exe]
  UDP    127.0.0.1:123          *:*
 [ntpd.exe]
  UDP    169.254.80.65:123      *:*
 [ntpd.exe]
  UDP    192.168.0.156:123      *:*
 [ntpd.exe]
  UDP    192.168.13.2:123       *:*
 [ntpd.exe]
  UDP    192.168.13.2:7900      *:*
 [MonitorService.exe]
  UDP    192.168.14.2:123       *:*
 [ntpd.exe]
  UDP    194.20.24.41:123       *:*
 [ntpd.exe]
  UDP    194.20.24.42:123       *:*
 [ntpd.exe]
  UDP    194.20.24.43:123       *:*
 [ntpd.exe]



2015年11月18日 星期三

Comapring Oracle Insert Performance Using append Parallel Hints

Comapring Oracle Insert Performance Using append Parallel Hints

Conclusion:
INSERT /*+ append PARALLEL(8) */ is faster by 20s outof 123s or 18.6%
SELECT /*+ PARALLEL(8) */ is faster by 22s out of 201s or 10.9%

Insert Test Background:
NDA File Set
f173NDAnor000.txt is 1.18 GB (1,275,150,301 bytes)

Insert Test Preparation:
-- drop tables 
BEGIN 
    Droptableifexist_proc('DITTOUSER.tblf173NDAnor000'); 
    Droptableifexist_proc('DITTOUSER.extf173NDAnor000'); 
END; 
/ 
-- create normal table 
CREATE TABLE dittouser.extf173ndanor000 
  ( 
     data XMLTYPE 
  ) xmltype data store AS securefile binary xml nologging; 

Insert Test Trials:
1. With Append Parallel 8
INSERT /*+ append PARALLEL(8) */ INTO dittouser.extf173ndanor000 
VALUES      (Xmltype(Bfilename('FULLBUILDDIR', 'f173NDAnor000.txt'), 
             Nls_charset_id('UTF8'))); 
1 rows inserted.
Elapsed: 00:01:41.013

2. With Append
INSERT /*+ append */ INTO dittouser.extf173ndanor000 
VALUES      (Xmltype(Bfilename('FULLBUILDDIR', 'f173NDAnor000.txt'), 
             Nls_charset_id('UTF8'))); 
1 rows inserted.
Elapsed: 00:01:40.281

2. With Parallel 8
INSERT /*+ PARALLEL(8) */ INTO dittouser.extf173ndanor000 
VALUES      (Xmltype(Bfilename('FULLBUILDDIR', 'f173NDAnor000.txt'), 
             Nls_charset_id('UTF8'))); 
1 rows inserted.
Elapsed: 00:01:39.112

4. Nothing
INSERT INTO dittouser.extf173ndanor000 
VALUES      (Xmltype(Bfilename('FULLBUILDDIR', 'f173NDAnor000.txt'), 
             Nls_charset_id('UTF8'))); 
1 rows inserted.
Elapsed: 00:02:03.759
Loading Speed is 1,275,150,301 bytes / 122.972 s = 10369436 Bytes/s = 9.89MB/s



SelectTest Background:
-- drop tables
BEGIN
    Droptableifexist_proc('DITTOUSER.tblf173NDAnor000');
END;
/
Select Test Trials:
1. With Parallel 8
CREATE TABLE dittouser.tblf173ndanor000
nologging AS
  (SELECT /*+ PARALLEL(8) */ domain,
                             name,
                             nametype,
                             serviceid,
                             qos,
                             pe,
                             fieldlistnumber,
                             source,
                             fields
   FROM   dittouser.extf173ndanor000,
          XMLTABLE('for $i in /Instruments/Instrument return $i' passing
  dittouser.extf173ndanor000.data COLUMNS name VARCHAR2(32) path 'Name', domain
  NUMBER(6) path 'Domain/@value', nametype NUMBER(3) path 'NameType/@value',
  serviceid NUMBER(5) path 'ServiceID/@value', qos NUMBER(3) path 'QoS/@value',
  pe NUMBER(6) path 'PE/@value', fieldlistnumber NUMBER(6) path
  'FieldListNumber/@value', source VARCHAR2(16) path 'Source', fields xmltype
  path 'FieldList/Field' )); 
table DITTOUSER.TBLF173NDANOR000 created.
Elapsed: 00:02:59.434


2. Nothing
CREATE TABLE dittouser.tblf173ndanor000
nologging AS
  (SELECT                    domain,
                             name,
                             nametype,
                             serviceid,
                             qos,
                             pe,
                             fieldlistnumber,
                             source,
                             fields
   FROM   dittouser.extf173ndanor000,
          XMLTABLE('for $i in /Instruments/Instrument return $i' passing
  dittouser.extf173ndanor000.data COLUMNS name VARCHAR2(32) path 'Name', domain
  NUMBER(6) path 'Domain/@value', nametype NUMBER(3) path 'NameType/@value',
  serviceid NUMBER(5) path 'ServiceID/@value', qos NUMBER(3) path 'QoS/@value',
  pe NUMBER(6) path 'PE/@value', fieldlistnumber NUMBER(6) path
  'FieldListNumber/@value', source VARCHAR2(16) path 'Source', fields xmltype
  path 'FieldList/Field' )); 
table DITTOUSER.TBLF173NDANOR000 created.
Elapsed: 00:03:21.970









2015年10月15日 星期四

Windows Batch Script to Test FTP List Command


http://www.howtogeek.com/howto/windows/how-to-automate-ftp-uploads-from-the-windows-command-line/




@echo off
echo USERNAME> ftpcmd.dat
echo PASSWORD>> ftpcmd.dat
echo ls>> ftpcmd.dat
echo ls >> ftpcmd.dat
echo ls >> ftpcmd.dat
echo ls >> ftpcmd.dat
echo ls >> ftpcmd.dat
echo quit >>  ftpcmd.dat

ftp -s:ftpcmd.dat IPADDRESS
del ftpcmd.dat

2015年10月13日 星期二

C++ Data Structure Alignment Example

#include <typeinfo>
#include <iostream>
#include <vector>
#include <stdint.h>
#include "SortedPointerVector.h"
using namespace std;

typedef uint32_t PartPosition;
typedef uint32_t PartDataLength;
typedef uint16_t PartNumber;
typedef uint32_t PartSize;

typedef uint16_t FieldPosition;
typedef uint16_t FieldDataLength;
typedef uint32_t FieldListLength;
typedef uint32_t FieldListPosition;

typedef int16_t Fid;
typedef uint8_t FieldType;

struct Struct1 // 8
{
       double d; // 8
};
struct Struct2 // 4
{
       int i; // 4
};
struct Struct3 // 2
{
       short s; // 2
};
struct Struct4 // 1
{
       bool b; // 1
};
struct Struct5 // 8
{
       char * c; // 8
};

struct Struct11      // 16
{
       bool b; // 1
       short s; // 2
       int i; // 4
       double d; // 8
};
struct Struct12      // 16
{
       double d; // 8
       int i; // 4
       short s; // 2
       bool b; // 1
};
struct Struct13      // 24
{
       int i; // 4
       double d; // 8
       short s; // 2
       bool b; // 1
};
struct Struct14      // 24
{
       bool b; // 1
       double d; // 8
       short s; // 2
       int i; // 4
};

struct Struct21      // 8
{
       char c[8]; // 8
};
struct Struct22      // 9
{
       char c[9]; // 9
};
struct Struct23 // 17
{
       char c1[9];
       char c2[8];
};
struct Struct24 // 24, because 8,1,8
{
       char c1[9];
       double d;
};
struct Struct25 // 16, because 8,2
{
       double d; // 8
       char c[2]; // 2
};
struct Struct26 // 16, because 8,2
{
       char c[2]; // 2
       double d; // 8
};
struct Struct27      // 8
{
       int i; // 4
       char c[2]; // 2
};
struct Struct28      // 8
{
       char c[2]; // 2
       int i; // 4
};

struct Struct31 // 34, because 17+17
{
       Struct23 s1; // 17
       Struct23 s2; // 17
};
struct Struct33  // 48
{
       Struct24 s1; // 24 (8,1,8)
       Struct24 s2; // 24 (8,1,8)
};
struct Struct34      // 24, because 8,2,2,8
{
       Struct25 s1; // 16 (8,2)
       Struct26 s2; // 16 (2,8)
};
struct Struct35 // 24, because (16,1),4, align 4
{
       Struct23 s1; // 17
       int i; // 4
};
struct Struct36 // 28, because (16,1),4,1+1+1, align 4
{
       Struct23 s1; // 17
       int i; // 4
       bool b1; // 1
       bool b2; // 1
       bool b3; // 1
};
struct Struct37 // 28, because (16,1),4,1+1+1+1, align 4
{
       Struct23 s1; // 17
       int i; // 4
       bool b1; // 1
       bool b2; // 1
       bool b3; // 1
       bool b4; // 1
};
struct Struct38 // 32, because (16,1),4,1+1+1+1,1, align 4
{
       Struct23 s1; // 17
       int i; // 4
       bool b1; // 1
       bool b2; // 1
       bool b3; // 1
       bool b4; // 1
       bool b5; // 1
};
struct Struct39 // 40, because (8,8,1),8,1+1+1+1+1, align 8
{
       Struct23 s1; // 17
       double d; // 8
       bool b1; // 1
       bool b2; // 1
       bool b3; // 1
       bool b4; // 1
       bool b5; // 1
};
struct Struct40 // 16, because 4,2,2,4, align 4
{
       Struct27 s1; // 4,2
       Struct28 s2; // 2,4
};

struct InstrumentName // 65
{
       static const uint64_t INSTRUMENT_NAME_LENGTH = 64;
       char name[INSTRUMENT_NAME_LENGTH]; // 64
       uint8_t size; // 1
};

struct InstrumentNameWrapper1 // 65
{
       InstrumentName n; // 65
};

struct InstrumentNameWrapper2 // 66, align 1
{
       InstrumentName n; // 65
       bool b; // 1
};
struct InstrumentNameWrapper3 // 72, because 64,1,4, align 4
{
       InstrumentName n; // 65
       int i; // 4
};

struct InstrumentKey // 72, because 64,1,2,2,1+1, align 2
{
       InstrumentName name; // 65 (64+1)
       uint16_t domain; // 2
       uint16_t serviceID; // 2
       uint8_t nameType; // 1
       uint8_t qos; // 1
};

struct InstrumentKey2 // 70, 2,2,66, align 2
{
       uint16_t domain; // 2
       uint16_t serviceID; // 2
       InstrumentName name; // 65 (64+1)
       uint8_t nameTypeQos; // 1
};

struct ConstituentKey // 1
{
       uint8_t constituentNumber;
};

struct PartSizes // 32
{
       std::vector<std::pair<PartNumber, PartSize>> contents;
};

struct PartDatas // 48, because 8,4,32, align 8
{
       char * data; // 8
       PartDataLength dataLength; // 4
    PartSizes partSizes; // 32
};

struct ConstituentData // 72, because 48,4+4,1+2+2+1+1+1,1+1, align 8
{
       PartDatas partDatas; // 48, align 8
       uint32_t pe; // 4
       uint32_t mask; // 4
       ConstituentKey key; // 1
       PartNumber lastPartNumber; // 2
       int16_t fieldListNumber; // 2
       uint8_t instrumentType; // 1
       bool isLastPartNumberKnown; // 1
       bool hasMultipleParts; // 1
       bool hasPE; // 1
       bool isContainShellMetaData; // 1
};
struct ConstituentData2 // 64, because 48,4+2+2,2+1+1+1+1+1+1, align 8
{
       PartDatas partDatas; // 48, align 8
       uint32_t mask; // 4
       uint16_t pe; // 2
       PartNumber lastPartNumber; // 2
       int16_t fieldListNumber; // 2
       ConstituentKey key; // 1
       uint8_t instrumentType; // 1
       bool isLastPartNumberKnown; // 1
       bool hasMultipleParts; // 1
       bool hasPE; // 1
       bool isContainShellMetaData; // 1
};

typedef SortedPointerVector<ConstituentKey, ConstituentData> ConstituentDataList; // 40

struct InstrumentContentData // 72, because 1+1+4,8,8,40,8
{
       uint8_t ll2Type; // 1
       bool isEverInstrumentAvailable; // 1
       uint32_t instrumentId; // 4
       int64_t lastUpdateTickCountInNanosec; // 8
       InstrumentKey * underlyingKey; // 8
       ConstituentDataList constituentDataList; // 40
       uint32_t mcLabel; // 4
};

struct InstrumentContentData2 // 64, because 40,8,8,4+2+1+1
{
       ConstituentDataList constituentDataList; // 40
       int64_t lastUpdateTickCountInNanosec; // 8
       InstrumentKey * underlyingKey; // 8
       uint32_t instrumentId; // 4
       uint16_t mcLabel; // 2
       uint8_t ll2Type; // 1
       bool isEverInstrumentAvailable; // 1
};

//-----------------------------------------------------------

template <class T>
void printSize()
{
       cout << typeid(T).name() << " : " << sizeof(T) << endl;
}

int main()
{
       cout << "primitive 1" << endl;
       printSize<Struct1>();
       printSize<Struct2>();
       printSize<Struct3>();
       printSize<Struct4>();
       printSize<Struct5>();

       cout << "struct 11" << endl;
       printSize<Struct11>();
       printSize<Struct12>();
       printSize<Struct13>();
       printSize<Struct14>();

       cout << "array 21" << endl;
       printSize<Struct21>();
       printSize<Struct22>();
       printSize<Struct23>();
       printSize<Struct24>();
       printSize<Struct25>();
       printSize<Struct26>();
       printSize<Struct27>();
       printSize<Struct28>();

       cout << "compund 31" << endl;
       printSize<Struct31>();
       printSize<Struct33>();
       printSize<Struct34>();
       printSize<Struct35>();
       printSize<Struct36>();
       printSize<Struct37>();
       printSize<Struct38>();
       printSize<Struct39>();
       printSize<Struct40>();

       cout << "real" << endl;
       printSize<InstrumentName>();
       printSize<InstrumentKey>();
       printSize<ConstituentDataList>();
       printSize<InstrumentContentData>();

       cout << "real 2" << endl;
       printSize<ConstituentData>();
       printSize<PartDatas>();
       printSize<PartSizes>();

       cout << "real modified" << endl;
       printSize<InstrumentNameWrapper1>();
       printSize<InstrumentNameWrapper2>();
       printSize<InstrumentNameWrapper3>();
       printSize<InstrumentContentData2>(); // saved 8 bytes
       printSize<ConstituentData2>();           // saved 8 bytes
       printSize<InstrumentKey2>();                    // saved 2 bytes

       system("PAUSE");

}

2023 Promox on Morefine N6000 16GB 512GB

2023 Promox on Morefine N6000 16GB 512GB Software Etcher 100MB (not but can be rufus-4.3.exe 1.4MB) Proxmox VE 7.4 ISO Installer (1st ISO re...