小编obl*_*obl的帖子

C++比写入文本文件的Bash脚本快得多

我想测试在bash脚本和C++程序中写入文件的性能.

这是bash脚本:

#!/bin/bash

while true; do
        echo "something" >> bash.txt
done
Run Code Online (Sandbox Code Playgroud)

这每秒向文本文件添加大约2-3 KB.

这是C++代码:

#include <iostream>
#include <fstream>

using namespace std;

int main() {
    ofstream myfile;
    myfile.open("cpp.txt");

    while (true) {
        myfile << "Writing this to a file Writing this to a file \n";
    }

    myfile.close();
}
Run Code Online (Sandbox Code Playgroud)

这在不到10秒的时间内创建了一个~6 GB的文本文件.

是什么让这个C++代码更快,和/或这个bash脚本这么慢?

c++ linux bash

17
推荐指数
2
解决办法
3195
查看次数

将多部分表单发布到Bamboo API

通过VB.NET控制台应用程序向BambooHR API提交多部分表单我遇到了很多困难.我发布了当前代码以及下面文档中的示例请求,当我运行此代码时,我得到(400)错误请求.我知道代码很乱,但我一直试图让它工作.

我能够通过使用他们的示例代码来使GET请求工作,但他们没有任何代码来执行此特定的API调用(上传员工文件).

任何帮助,将不胜感激.

这是我的代码:

Sub Main()

    upload(id, "https://api.bamboohr.com/api/gateway.php/company")

    Console.WriteLine()
    Console.WriteLine("Press ENTER to quit")
    Console.ReadLine()
End Sub

Function upload(ByVal employeeId As Integer, ByVal baseUrl As String)

    ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 Or SecurityProtocolType.Ssl3

    Dim boundary = "----BambooHR-MultiPart-Mime-Boundary----"
    Dim url = String.Format("{0}/v1/employees/{1}/files/", baseUrl, employeeId)

    Dim request As HttpWebRequest = WebRequest.Create(url)
    request.KeepAlive = True
    request.Method = "POST"
    request.ContentType = "multipart/form-data; boundary=" + boundary

    'Authorization is just the api key and a random string, in this case is x
    '
    Dim authInfo As String = …
Run Code Online (Sandbox Code Playgroud)

vb.net post multipartform-data .net-4.5

11
推荐指数
1
解决办法
868
查看次数

请参阅POST多部分表单数据请求

我正在尝试通过C#和VB.NET控制台应用程序提交多部分表单,但我怎么看它实际上是什么样的?我在一些论坛上看到你可以通过WireShark看到它的样子.我需要将它与API文档相匹配.任何帮助,将不胜感激!

c# vb.net multipartform-data wireshark .net-4.5

6
推荐指数
1
解决办法
230
查看次数

如何在DataGridView上创建固定的背景

我做了一个自定义控件继承DataGridView,以便有一个透明的背景.现在我试图在计时器上设置一个滚动功能,每秒向下滚动一行.但是,当我尝试滚动(垂直)时,背景图像不固定.滚动时有没有办法使背景图像固定?

编辑:这是处理滚动计时器的代码.

Private Sub Sub1

    'Some previous code

    If DataGridView1.Rows.Count > 10 Then
        ScrollIndex1 = 0 'Integer for scroll index
        DGVAutoScroll()
    End If

End Sub

Private Sub DGVAutoScroll()

    Timer2.Enabled = True
    Timer2.Interval = 1000

End Sub

Private Sub Timer2_Tick(sender As Object, e As EventArgs) Handles Timer2.Tick

    If ScrollIndex1 = DataGridView1.Rows.Count - 1 Then
        ScrollIndex1 = 0
        DataGridView1.FirstDisplayedScrollingRowIndex = ScrollIndex1
        ScrollIndex1 += 1
    Else
        DataGridView1.FirstDisplayedScrollingRowIndex = ScrollIndex1
        ScrollIndex1 += 1
    End If

End Sub

'Custom DataGridView class
Imports System.ComponentModel …
Run Code Online (Sandbox Code Playgroud)

vb.net datagridview

2
推荐指数
1
解决办法
546
查看次数

Unity3D C#定时器以毫秒为单位显示

我正在尝试将.text更改为以下格式:

00:00:00

但相反,我得到0:00.00000我需要更改以更正我的代码?

private void Update()
{
    if (!chestButton.IsInteractable ()) 
    {
        if (IsChestReady ()) {
            chestButton.interactable = true;
            chestTimer.SetActive (false);
            chestTimerBg.SetActive (false);
            newGift.SetActive (true);
            return;
        }
        //Set Timer
        ulong diff = ((ulong)DateTime.Now.Ticks - lastChestOpen);
        ulong m = diff / TimeSpan.TicksPerMillisecond;
        float secondsLeft = (float)(msToWait - m) / 1000.0f;

        string r = " ";
        //Hours
        r += ((int)secondsLeft / 3600).ToString() + ": ";
        secondsLeft -= ((int)secondsLeft / 3600) * 3600;
        //Minutes
        r += ((int)secondsLeft / 60).ToString();
        //Seconds
        r += (secondsLeft % …
Run Code Online (Sandbox Code Playgroud)

c# android unity-game-engine

2
推荐指数
1
解决办法
752
查看次数