[완료] 리눅스에서 ns(나노초) 까지 시간 정보를 얻을 수 있는 방법은 없나요?

nyxanox의 이미지

안녕하세요.

매번 질문이 있을때 도움을 요청하게 되네요.
혹시 리눅스에서 ns까지 시간을 얻어 오는 방법은 없나요?
ps까지 얻어 올 수 있으면 더 좋을 것 같습니다.

부탁드립니다. (- -)(_ _)

bushi의 이미지

[bushi@rose t]$ man -k timespec
clock_gettime []     (2)  - Return the current timespec value of tp for the specified clock
[bushi@rose t]$

man -WK timespec
도 해보세요. 여러가지 나옵니다.

OTL

nyxanox의 이미지

안녕하세요~ 답변 감사합니다.
근데 저는 왜 안 나오는 것일까요?
man 페이지가 없는거 같은데;;

Good luck, dandy kang!

trinite의 이미지

kernel에서 high resolution 체크되어있어야합니다.
그냥 컴파일하면 저 옵션이 안켜져있던 것 같던데 그러면 nano까지 못얻어요 ^^

Senior Engineer

jeongheumjo의 이미지

timespec 구조체의 32비트가 다 되는 그날 지구가 멸망할 수도... ㅎㅎㅎ

a287848의 이미지

실제로 커뮤니티에서도 그리 심각하게 받아들이지 않는 분위기던대요..

Dig it.

Dig it.

jeongheumjo의 이미지

제가 유머감각이 좀 없습니다.
최근에 이와 관련된 내용을 타이머 공부하다가 알게되고는 신기해서 그렇게 적었어요...
관심을 받고 싶어하는 이런 글(위에님 말고 제 글 얘기예요)들을 쓰고싶어하기 때문에 인터넷 상에서는 때로는 악플로 나타나기도 하는 것 같아요..
어디까지나 썰렁한 농담이었습니다~

송효진의 이미지

지구는 이미 멸망의 위기를 몇번이나 넘겨왔습니다.
공포의 대왕에서 부터...
1111111111 일도 넘겼고,
1234567890 (올해 발렌타인데이)도 무사히 넘겼죠.

2121212121 (2037-03-21) 이 유력할 것 같은데...===33=3

ps. 경험상 (쓰기 싫지만) ㅎㅎ ㅋㅋ ===3=3=3 등을 많이 써 주어야 농담이 되더군요-_-;

emerge money
http://wiki.kldp.org/wiki.php/GentooInstallSimple - 명령어도 몇 개 안돼요~
http://xenosi.de/

nyxanox의 이미지

위에 답변 주신분들 감사합니다.
약간 재미있는 답변도 있었네요 ㅎㅎㅎ
ns까지 쓰는 방법은

timespec 구조체 변수를 하나 선언하고

getnstimeofday($timespec 구조체 변수);

로 받아오면 되더군요 ㅎㅎ

time.h와 time.c를 참고하세요

#define _STRUCT_TIMESPEC
struct timespec {
	time_t	tv_sec;		/* seconds */
	long	tv_nsec;	/* nanoseconds */
};

void getnstimeofday(struct timespec *tv)
{
	struct timeval x;
 
	do_gettimeofday(&x);
	tv->tv_sec = x.tv_sec;
	tv->tv_nsec = x.tv_usec * NSEC_PER_USEC;
}

Good luck, dandy kang!

bushi의 이미지

헐.
이런 식이면 pico, femto, atto, zepto, yocto 의 영역에 도전하셔도 되겠습니다.

OTL

nyxanox의 이미지

getnstimeofday($timespec 구조체 변수);
가 아니라
getnstimeofday(&timespec 구조체 변수);
입니다;;;

Good luck, dandy kang!

klyx의 이미지

농담하신거 맞지요...?

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.