如何设置配置SolidCp连接

时间:2018-03-07 10:05:07

标签: websitepanel

我想使用solidCP,所以我创建了一个项目,我添加了所需的SolidSet Dlls,我添加了一个Class来配置它,我创建了一个连接到solidcp的连接,但我需要一个示例代码来配置它并设置用户,传递,...我发送我的示例代码帮助我...

密码,用户名,Apiurl设置为例如

class Person
{
using ushort = unsigned short;
private:
    std::string name_;
    ushort      age_;
public:
    static constexpr size_t nr_ctors = 3;
    static const char * const ctor_signature[nr_ctors];

    enum class CTOR_1
    {   CTOR = 0
    };
    enum class CTOR_2
    {   CTOR = 1
    };
    enum class CTOR_3
    {   CTOR = 2
    };

    explicit Person(const std::string &name, ushort age,CTOR_1) 
    {   name_ = name;
        age_  = age;
    }
    explicit Person(const std::string &name, ushort age, CTOR_2) : name_{name},age_{age}
    {}
    explicit Person(std::string name,ushort age,CTOR_3) : name_{std::move(name)},age_{age}
    {}
};

const char * const Person::ctor_signature[Person::nr_ctors] = {"\nexplicit Person(const std::string &name, ushort age,CTOR_1)",
                                                               "\nexplicit Person(const std::string &name, ushort age, CTOR_2) : name_{name},age_{age}",
                                                               "\nexplicit Person(std::string name,ushort age,CTOR_3) : name_{std::move(name)},age_{age}"};

using mclock        = std::chrono::high_resolution_clock;
using time_p_t      = std::chrono::time_point<mclock>;
using precision_t   = std::chrono::nanoseconds;

#define NR_ITERATIONS   (128 * 1024)

template <typename Ty_>
precision_t time_no_heap(const std::string &name)
{
    time_p_t t_0;
    time_p_t t_1;

    t_0 = mclock::now();
    Person p = Person{name,66,Ty_::CTOR};
    t_1 = mclock::now();

    return t_1 - t_0;
}

template <typename Ty_>
precision_t time_with_heap(const std::string &name)
{
    time_p_t t_0;
    time_p_t t_1;
    Person   *p_person;

    t_0 = mclock::now();
    p_person = new Person{ name,66,Ty_::CTOR };
    t_1 = mclock::now();
    delete p_person;

    return t_1 - t_0;
}

void print_statistics(int iterations, size_t str_size, const precision_t(&stats)[2][Person::nr_ctors])
{
    std::cout << "\nTotal iterations : " 
              << iterations
              << "\nString ize : "
              << str_size
              << std::endl;
    for (int i = 0; i < Person::nr_ctors; ++i)
    {   std::cout << Person::ctor_signature[i]
                  << "\n\t Stack (ms) : " 
                  << std::chrono::duration_cast<std::chrono::duration<double, std::milli>>(stats[0][i]).count()
                  << "\n\t Heap (ms)  : "
                  << std::chrono::duration_cast<std::chrono::duration<double, std::milli>>(stats[1][i]).count()
                  << std::endl;
    }
}

int main(int argc, const char *argv[])
{   
    int         iterations;
    std::string *p_name;

    if (argc != 3 && argc != 1)
    {   std::cout << "USAGE [<iterations>K <string size>]" << std::endl;
        return -1;
    }
    else if (argc == 3)
    {   iterations = std::atoi(argv[1]) * 1024;
        p_name = new std::string(std::atoi(argv[2]), 'x');
    }
    else
    {   iterations = NR_ITERATIONS;
        p_name = new std::string{ "Benchmark" };
    }

    precision_t benchmark  [2][Person::nr_ctors]{};

    std::cout << "\nUsing string : " << *p_name << ".\nIterating : " << iterations << " times." << std::endl;

    for (auto i = iterations; --i >= 0; )
    {   //Stack allocation
        benchmark[0][(int)Person::CTOR_1::CTOR] += time_no_heap<Person::CTOR_1>(*p_name);
        benchmark[0][(int)Person::CTOR_2::CTOR] += time_no_heap<Person::CTOR_2>(*p_name);
        benchmark[0][(int)Person::CTOR_3::CTOR] += time_no_heap<Person::CTOR_3>(*p_name);
        //Heap allocation
        benchmark[1][(int)Person::CTOR_1::CTOR] += time_with_heap<Person::CTOR_1>(*p_name);
        benchmark[1][(int)Person::CTOR_2::CTOR] += time_with_heap<Person::CTOR_2>(*p_name);
        benchmark[1][(int)Person::CTOR_3::CTOR] += time_with_heap<Person::CTOR_3>(*p_name);
    }

    print_statistics(iterations,p_name->size(),benchmark);

    delete p_name;

    return 0;
}

非常感谢...

0 个答案:

没有答案