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.

709 questions
1519
votes
38 answers

How to measure elapsed time in Python?

What I want is to start counting time somewhere in my code and then get the passed time, to measure the time it took to execute few function. I think I'm using the timeit module wrong, but the docs are just confusing for me. import timeit start =…
gilbert8
  • 15,207
  • 3
  • 12
  • 3
785
votes
14 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
  • 20,387
  • 19
  • 57
  • 135
211
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
111
votes
7 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 codes? Something that does this: import some_time_library starttime =…
alvas
  • 94,813
  • 90
  • 365
  • 641
65
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…
MonsterMMORPG
  • 20,310
  • 69
  • 183
  • 306
50
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,440
  • 2
  • 17
  • 21
37
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
  • 373
  • 1
  • 3
  • 4
35
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
  • 351
  • 1
  • 3
  • 3
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,471
  • 12
  • 57
  • 103
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
21
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
  • 9,023
  • 26
  • 84
  • 145
17
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,157
  • 6
  • 19
  • 26
14
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,473
  • 7
  • 59
  • 111
13
votes
1 answer

addOnLayoutChangeListener vs addOnGlobalLayoutListener vs post(Runnable r)

PROBLEM: Suppose we have simple case: we have view and we have to show some data on this view. We use static method showData(View view) to do this. I want to know the exact moment when view layout is measured and I can access getWidth() getHeight()…
comte1986
  • 149
  • 1
  • 5
13
votes
6 answers

Why is my android custom view not square?

I created a custom view to display a gameboard for a game I'm developing. The gameboard needs to be a square at all times. So with and height should be the same. I followed this tutorial to achieve this. I added the following code to my custom…
Peter Fortuin
  • 4,462
  • 8
  • 36
  • 65
1
2 3
47 48