我正在努力下载一个软件上的文件,这是我得到的,它的sucesfully下载,我也可以取得进展,但还有一件事,我不知道该怎么做.测量下载速度.我很感激你的帮助.谢谢.这是当前的下载方法代码
public void run()
{
OutputStream out = null;
URLConnection conn = null;
InputStream in = null;
try
{
URL url1 = new URL(url);
out = new BufferedOutputStream(
new FileOutputStream(sysDir+"\\"+where));
conn = url1.openConnection();
in = conn.getInputStream();
byte[] buffer = new byte[1024];
int numRead;
long numWritten = 0;
double progress1;
while ((numRead = in.read(buffer)) != -1)
{
out.write(buffer, 0, numRead);
numWritten += numRead;
this.speed= (int) (((double)
buffer.length)/8);
progress1 = (double) numWritten;
this.progress=(int) progress1;
}
}
catch (Exception ex)
{
echo("Unknown Error: …Run Code Online (Sandbox Code Playgroud)
您好,我正在学习使用C#VS 2010 EE编程,我正在编写一个应用程序来填写预打印表单.这个表格在不同的坐标中有几个地方.纸上的三个盒子是多行5"W x 2"H盒子.
我已经创建了窗体,窗体上TextBox的每个位置都有一个窗口.
问题是,当在这些多行文本框中输入信息时,我需要知道在纸上留下多少行来输入更多文本,以及何时停止输入,因为PrePrinted框中没有更多可用空间.
我做了很多搜索,但我发现的一切都是关于在屏幕上进行测量,这与纸张上的最终结果不符.
换句话说,我需要知道如何在输入TextBoxes时找出纸张上的字符串尺寸,并将其与PrePrinted表单上的可用空间进行比较,这样我就可以在它经过之前停止纸盒上的底边框.
纸张上的第一个盒子的高度为5英寸,宽度为2英寸,从" new RectangleF(60.0F, 200.0F, 560.0F, 200.0F)" 开始.我明白这些数字是百分之一英寸.
所有这一切,考虑到我不能通过字符数限制TextBoxes,因为并非所有字符占用相同的空间,如H != I; M != l; 等.
预先感谢您的帮助.今天是2011年9月5日,基于您的意见和建议,我已将代码更改为使用Graphics.MeasureString.
这是我现在使用Graphics.MeasureString和只有一个richTextBox的代码:从printDocument1_PrintPage事件中完美地工作,但我不知道如何使它从richTextBox1_TextChanged事件中运行.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Printing;//Needed for the PrintDocument()
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Printing
{
public partial class Form1 : Form
{
private Font printFont1;
string strPrintText;
public Form1()
{
InitializeComponent();
}
private void cmdPrint_Click(object sender, EventArgs e)
{
try …Run Code Online (Sandbox Code Playgroud) 我使用多维数据集作为数据源和我的数据集上的MDX查询创建了一个报告.我在我的数据集中有一些度量,但我想显示至少有一个度量> 0的行,使用像OR过滤器(measure1> 0或度量2> 0 ..etc)这样做我怎么能这样做?
谢谢
我想以某种方式从二进制文件中获取"执行的汇编程序指令数".考虑以下代码:
if(password[0] == 'p') {
if(password[1] == 'a') {
......
printf("Correct Password\n");
}
}
Run Code Online (Sandbox Code Playgroud)
然后,如果我用例如"abc"启动程序,它将不会采用第一个分支,因此它将执行较少的指令.如果我输入"pbc"它将采用第一个分支,因此它将执行更多(约4-5)指令.(这是CTF(捕获标志)文件的一些研究).所以我的想法是反转二进制并试图理解算法,我使用更快的方法来计算不同设置的执行汇编指令的数量(如不同的字符或密码长度等等,看看我是否可以采取另一个分支使用另一个输入,从而创建更多的汇编指令).
我的基本想法是编写一个简单的调试器,只需在当前指令之后放置一个int3,递增一个计数器,反汇编下一条指令,并在该指令后放置一个int3(我的想法的强简化版本).
是否有任何程序/库/ ...已经完成了那些东西?(因为当程序处理信号时我看到一些问题,...)
(我已经尝试使用高精度计时器来测量时间,但这是完全失败的,因为差异只有4-5条指令)
为什么lColorWheel.getWith()方法返回0?我想这与onMeasure事件有关,但我真的无法从文档中了解它是如何工作的.我必须为mDrawable设置尺寸?
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_light);
ShapeDrawable mDrawable;
ivColorWheel=(ImageView)findViewById(R.id.ivColorWheel);
lColorWheel=findViewById(R.id.lColorWheel);
ld=(LayerDrawable)getResources().getDrawable(R.drawable.colorwheel);
mDrawable = new ShapeDrawable(new OvalShape());
mDrawable.setIntrinsicWidth(lColorWheel.getWidth());
mDrawable.setIntrinsicHeight(lColorWheel.getHeight());
Log.d("lColorWheel.getWidth()",Integer.toString(lColorWheel.getWidth())); //returns 0, why?
Log.d("lColorWheel.getHeight()",Integer.toString(lColorWheel.getHeight())); //returns 0, why ?
Run Code Online (Sandbox Code Playgroud)
和适当的XML文件:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/background"
android:gravity="center_horizontal"
android:addStatesFromChildren="true" >
<RelativeLayout
android:id="@+id/lColorWheel"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="20dp"
android:layout_centerHorizontal="true"
android:adjustViewBounds="true">
<ImageView
android:id="@+id/ivColorWheel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:adjustViewBounds="true"
android:paddingBottom="0dp"
android:paddingTop="0dp"
android:src="@drawable/iconwheel"
/>
<ImageView
android:id="@+id/ivCenterButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:maxHeight="5dp"
android:maxWidth="5dp"
android:onClick="clc"
android:paddingBottom="0dp"
android:paddingLeft="0dp"
android:paddingRight="0dp"
android:paddingTop="0dp"
android:src="@drawable/center3" />
</RelativeLayout>
<SeekBar
android:id="@+id/sbColorIntensity"
android:layout_width="match_parent"
android:layout_height="50dp" …Run Code Online (Sandbox Code Playgroud) 我需要显示一个带有居中标签的表单(根据表单的宽度和标签的文本,宽度,字体系列和字体大小).到目前为止,这是我的尝试:
(Me.Width - TextRenderer.MeasureText("Hello word", New Font("Delius", 10,
FontStyle.Regular).Width) / 2
Run Code Online (Sandbox Code Playgroud)
无论我尝试多少,标签都不会出现应该居中的位置(标签的左右两侧看起来不一样).
无论使用哪种字体,还有其他方法来测量文本吗?谢谢.
如何构建DAX度量来计算特定月份的YTD值之和?
在这里,我们将FactTable按月分组.FactTable充满了实际数据和预测数据.知道何时实际结束的唯一方法是[年末截止日期]列[年末截止日期]中的信息.在[年终截止日期]列[年末截止日期]中 - 它是一个单值表 - 我们有一个有趣的选择月份,我们希望看到YTD的计算.在我们的例子中,它是三月.FactTable每月不定期更新,通常延迟一个月.由于不规则的更新,无法将其链接到像TODAY这样的时间函数.
我们希望在黄色Card Visual中显示正确的YTD值[月末] [YTD].当我们点击"2018-03"上的切片机时,我们几乎得到了我们想要的东西 - 在黄卡中正确值为66.但是这种解决方案不是自动的.我想在[年末]月份变化时自动查看正确的值,在我们的情况下是4月或5月.我不希望用户完成它.
我的绝望努力可以从文件:DAX YTD.pbix下载
我以各种方式追赶鹿:
我很感激你的帮助.
在赏金之前更新. 走向更高的水平.我已经向FactTable引入了一个Category列.请按category.pbix下载DAX YTD.所以过滤现在变得更加复杂.我想为苹果类别提供正确的YTD数据.
我有一个TextView,显示更改和运行时间的文本.我想使用View.getLineCount()方法来查看TextView占用多少行并相应地执行不同的功能.问题是我需要确定TextView在相同方法中占用的行数,需要知道它占用了多少行.我试过在两次调用之间调用View.invalidate(),但似乎没有解决任何问题.如果可能的话,我想测量行数而不渲染视图,但如果我必须渲染它,我也会愿意这样做.如果这不够具体,请告诉我,我会尝试更具体.谢谢!
我正在调试一个C应用程序,我想知道它在特定函数中花费了多少时间.
我可以更改源代码并添加更多代码来进行测量,但对我来说似乎并不合适.我宁愿用外部应用程序来做,而不是每次都重新编译.
我发现可以在GDB中设置一个断点,所以我想,必须能够通过简单的程序使用类似工具跟踪时间: - 设置断点 - 停止时,测量实际时间并运行函数 - 离开函数时,再次测量时间然而,我还没有找到一种方法如何在gdb中做到这一点:(
有任何想法吗?谢谢
我正在尝试获取在节点获取操作中执行的异步函数的执行/响应时间,如下所示
async function getEditedData() {
var a = await fetch(`https://api.example.com/resorce_example`);
var b = await a.json();
// Some aditional treatment of the object obtained (b)
console.log("End of the asynchronous function")
}
Run Code Online (Sandbox Code Playgroud)
我像这样使用了库 perf_hooks,但执行时间显示之前
const hrtime = require ('perf_hooks').performance.now ;
var start = hrtime ();
getEditedData();
var end = hrtime ();
console.log (end - start);
Run Code Online (Sandbox Code Playgroud)
我找到了 async_hooks 库https://nodejs.org/api/perf_hooks.html#perf_hooks_measuring_the_duration_of_async_operations,但我不明白它是如何工作的。我是 javascript/nodejs 的基础