有3个阶段 - 构建,测试和部署.gitlab-ci.yml
.
需要运行夜间回归测试阶段 - 好nightly
:)
这是相关的.gitlab-ci.yml
代码:
stages:
- build
- test
- deploy
build_project:
stage: build
script:
- cd ./some-dir
- build-script.sh
except:
- tags
#Run this only when say variable 'NIGHTLY_TEST == True'. But HOW?
nightly_regression_test_project:
stage: test
script:
- cd ./some-dir
- execute test-script
Run Code Online (Sandbox Code Playgroud)
每天标记到only
运行test
阶段是不可取的.
还有其他想法吗?
class B
{
public:
operator B() const{ } // What is this and what is the purpose?
private:
int m_i;
};
Run Code Online (Sandbox Code Playgroud)
所以问题是,转换运算符或构造函数运算符是什么用的呢?在哪里使用它?
任何人都可以在STL sort
算法的背景下解释这种行为吗?如果operator <
没有定义const
它会给出错误,
error: passing ‘const B’ as ‘this’ argument of ‘bool B::operator<(const B&)’ discards qualifiers [-fpermissive]
while (__pivot < *__last)
是sort
算法中LHS const
对象,或者sort
是const
方法?
class B
{
public:
...
bool operator < (const B& b) const // why const required here?
{
return (m_i < b.m_i);
}
...
private:
int m_i;
int m_j;
};
int main()
{
vector<B> Bvec2 {B(5), B(3), B(30), B(20), B(8)};
std::sort(Bvec2.begin(), Bvec2.end());
...
}
Run Code Online (Sandbox Code Playgroud) int iGlobe = 0;
...
void thread1Func()
{
Lock(&Mutex1);
if(iGlobe == 0) //step-1
someaction();
}
...
void thread2Func()
{
Lock(&Mutex2);
iGlobe = 5; //step-2
}
Run Code Online (Sandbox Code Playgroud)
假设,
1)Thread1执行步骤1并进入休眠状态
2)同时Thread2执行步骤2并改变iGlobe的值
如何克服这种情况?
我正在使用 c++11 (g++ v4.7.2)
我已经为“基”类重载了运算符 new 和运算符删除。显然,他们不应该在调用 new/delete 时调用构造函数/析构函数,因为我没有在重载的 new/delete 中实现 ctor/dtor 调用。但输出却与此相反
//Output of below program
Base new opnd.cpp 87
Base ctor
10
Base dtor
Base delete
Run Code Online (Sandbox Code Playgroud)
为什么重载运算符 new/delete 会调用 ctor/dtor?
#include <iostream>
using namespace std;
#define NEW new(__FILE__, __LINE__)
#define DELETE delete
class Base
{
public:
Base():m_i(10){ cout << "Base ctor" << endl; }
virtual ~Base(){ cout << "Base dtor" << endl; }
void* operator new(size_t size, const char* file, int line) throw(std::bad_alloc);
void operator delete(void *rawMem, size_t …
Run Code Online (Sandbox Code Playgroud) void perfprint(unsigned int count)
{
char a[100] = "fosjkdfjlsjdflw0304802";
for(unsigned int i = 0;i<count;++i)
{
printf("%s", a);
}
}
void perfcout(unsigned int count)
{
char a[100] = "fosjkdfjlsjdflw0304802";
for(unsigned int i = 0;i<count;++i)
{
cout << a;
}
}
Run Code Online (Sandbox Code Playgroud)
环境:C++,VS 2010,Windows 7,32位,Core-i7,4GB,3.40 GHz
我测试了与功能count = 10000
为5
次,每次.使用测量性能QueryPerformanceCounter
.
perfprint> perfprint
毫秒(5次运行的平均值)
perfcout> ~850
毫秒(5次运行的平均值)
这是否意味着printf perfcout
比cout更快
编辑:
使用/ Ox,/ Ot,Release版本中没有调试信息
并用~9000
在perfcout方法,结果是为相同printf
,即~10x
编辑2:
总而言之,cout
比快std::ios_base::sync_with_stdio(false);
.上述观察的原因是由于控制台输出.当将输出重定向到文件时,事情开始转向!
struct st{
int a;
char *ptr;
}obj;
main()
{
obj.a=10;
obj.ptr="Hello World"; // (1) memory allocation?
printf("%d,%s",obj.a,obj.ptr);
}
Run Code Online (Sandbox Code Playgroud)
ptr
在struct中声明.Hello world
发生分配时,未分配内存,但此程序正常工作并正确输出.在标记处完成作业时,它不应该失败/崩溃(1)
吗?