| Type | time | ms | comment |
|---|---|---|---|
| L1 cache reference | 0.5 ns | ||
| Branch mispredict | 5 ns | ||
| L2 cache reference | 7 ns | 14x L1 cache | |
| Mutex lock/unlock | 25 ns | ||
| Main memory reference | 300 ns | 20x L2 cache, 200x L1 cache |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import win32com.client as win32 | |
| import time | |
| import sys | |
| import os | |
| import shutil | |
| def sendonemail(addr = "", attach = "", subject = ""): | |
| outlook = win32.Dispatch('outlook.application') | |
| mail = outlook.CreateItem(0) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <cstring> | |
| #include <cstdlib> | |
| #include <cassert> | |
| #include <string> | |
| #include <vector> | |
| #include <stdexcept> | |
| #include <iostream> | |
| int chartoint(char c) { | |
| const char* buf = "0123456789abcdef"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <vector> | |
| #include <iostream> | |
| #include <cstdio> | |
| using namespace std; | |
| pair<int, int> findNumber(const vector<int>& vec) { | |
| int xsum = 0; | |
| int sz = vec.size(); | |
| // calc for total arrary |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| string generate_code() { | |
| const int kcodelength = 25; | |
| char res[kcodelength + 10]; | |
| string buffer = "1234567890abcdefghijklmnopqrstuvwzyz" | |
| "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; | |
| int len = buffer.length(); | |
| int idx = 0; | |
| for (int i = 0; i < kcodelength; ++i) { | |
| char tmp = buffer[rand() % len]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // A simple demo aimed to test the time efficiency for the find operation | |
| // in C++ STL containers, used in vector,map and unordered_map, respectively. | |
| #include <vector> | |
| #include <map> | |
| #include <algorithm> | |
| #include <unordered_map> | |
| #include <cstdio> | |
| #include <ctime> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| int | |
| binary_search_first_position(int *A, int n, int target) { | |
| int end[2] = { -1, n }; | |
| while (end[0] + 1 < end[1]) { | |
| int mid = (end[0] + end[1]) / 2; | |
| int sign = (unsigned)(A[mid] - target) >> 31; | |
| end[1-sign] = mid; | |
| } | |
| int high = end[1]; | |
| if (high >= n || A[high] != target) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <iostream> | |
| #include <algorithm> | |
| #include <set> | |
| #include <map> | |
| #include <cstring> | |
| #include <cstdlib> | |
| #include <cstdio> | |
| #include <vector> | |
| using namespace std; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <iostream> | |
| #include <queue> | |
| #include <cmath> | |
| #include <cstdio> | |
| #include <cstring> | |
| #include <vector> | |
| #include <algorithm> | |
| using namespace std; | |
| const int msize = 500; |