Questions tagged [measure]

Measuring means to determine how big is a certain entity. In computing, it's often referred to calculating the size(s) of a screen.

Measuring means to determine how big is a certain entity. In computing, it's often referred to calculating the size(s) of a screen.

936 questions
2019
votes
41 answers

How do I measure elapsed time in Python?

I want to measure the time it took to execute a function. I couldn't get timeit to work: import timeit start = timeit.timeit() print("hello") end = timeit.timeit() print(end - start)
gilbert8
  • 20,223
  • 3
  • 14
  • 3
1008
votes
15 answers

How do I measure request and response times at once using cURL?

I have a web service that receives data in JSON format, processes the data, and then returns the result to the requester. I want to measure the request, response, and total time using cURL. My example request looks like: curl -X POST -d @file…
sdasdadas
  • 23,917
  • 20
  • 63
  • 148
213
votes
16 answers

How to retrieve the dimensions of a view?

I have a view made up of TableLayout, TableRow and TextView. I want it to look like a grid. I need to get the height and width of this grid. The methods getHeight() and getWidth() always return 0. This happens when I format the grid dynamically…
greenset
158
votes
12 answers

How to measure time taken between lines of code in python?

So in Java, we can do How to measure time taken by a function to execute But how is it done in python? To measure the time start and end time between lines of code? Something that does this: import some_time_library starttime =…
alvas
  • 115,346
  • 109
  • 446
  • 738
81
votes
7 answers

How to calculate distance similarity measure of given 2 strings?

I need to calculate the similarity between 2 strings. So what exactly do I mean? Let me explain with an example: The real word: hospital Mistaken word: haspita Now my aim is to determine how many characters I need to modify the mistaken word to…
Furkan Gözükara
  • 22,964
  • 77
  • 205
  • 342
54
votes
2 answers

What triggers a View's measure() to be called

In my application I have an infinite loop on one of my View's onMeasure() overrides. Debugging the source code starting from a break point in my onMeasure, I am able to trace myself all the way up the stack trace up to the PhoneWindow$DecorView's…
C Nick
  • 2,500
  • 2
  • 17
  • 21
39
votes
4 answers

Measure time of execution in F#

Please post code for displaying time in F#. I noticed that you can measure it from F# interactive with #time directive, but I don't know how to execute program from FSI Thanks
nanek
  • 391
  • 1
  • 3
  • 3
39
votes
8 answers

Measure execution time in C#

I want to measure the execution of a piece of code and I'm wondering what the best method to do this is? Option 1: DateTime StartTime = DateTime.Now; //Code TimeSpan ts = DateTime.Now.Subtract(StartTime); string elapsedTime =…
Jake
  • 393
  • 1
  • 3
  • 4
28
votes
1 answer

getMeasuredWidth returns totally wrong value

I have to measure a View for spacing others. I use this code for that: ViewGroup view = ...; view.setPadding(10, 0, 10, 0); int wrapContent = RelativeLayout.LayoutParams.WRAP_CONTENT; int specWidth = MeasureSpec.makeMeasureSpec(wrapContent,…
WonderCsabo
  • 11,947
  • 13
  • 63
  • 105
24
votes
4 answers

How can I measure the execution time of a npm/yarn task/script?

How can I measure the execution time of a npm/yarn task on the command line without modifying the scripts. In my special use case I want to execute an existing E2E-Test (yarn test:e2e) 100 times and take the average value.
user3025289
23
votes
8 answers

View's getWidth() and getHeight() returning 0

I have looked at the similar questions and tried their solutions, but it didn't work for me. I'm trying to read width of an imageView, but it is returning 0. Here is the code: public class MainActivity extends Activity { private ImageView image1; …
yrazlik
  • 10,411
  • 33
  • 99
  • 165
21
votes
2 answers

Find chest size using Kinect v2

I need to find out the front measure of chest for any individual using Kinect while facing the camera. My current solution is: When a MultiFrameSource arrives get the color (to display the body in the ui) body (to get the Joints), and bodyIndex…
Alberto Godar
  • 249
  • 1
  • 7
19
votes
3 answers

React-Native : measure a View

I'm trying to measure a view using a ref, but the width returned is 0 despite the fact that I see the view displayed on the screen (and it's far from being equal to 0). I tried to follow this : https://github.com/facebook/react-native/issues/953 but…
ilansas
  • 5,899
  • 6
  • 21
  • 27
15
votes
5 answers

How do I measure the size of a TextBlock in WPF before it is rendered?

I have a WPF DataTemplate with two TextBlock controls (stacked) and then some other elements underneath. Due to some complicated layout code, I need to know the height of the two TextBlock elements so that I can draw some fancy connector lines, and…
Scott Whitlock
  • 13,739
  • 7
  • 65
  • 114
14
votes
1 answer

How can I measure CPU time of a specific set of threads?

I run C++ program in Linux. There are several threads pool (for computation, for io, for ... such things). The system call clock() gives me a way to measure the CPU time spent by all the CPU cores for the process. However, I want to measure the CPU…
syko
  • 3,477
  • 5
  • 28
  • 51
1
2 3
62 63